afuna: Cat under a blanket. Text: "Cats are just little people with Fur and Fangs" (Default)
afuna ([personal profile] afuna) wrote in [site community profile] changelog2010-01-21 01:39 pm

[dw-free] Prohibit Conditional Declarations (backend cleanup)

[commit: http://hg.dwscoalition.org/dw-free/rev/9d643eb74e56]

http://bugs.dwscoalition.org/show_bug.cgi?id=2270

Avoid potential pitfall: cgi-bin.

Patch by [personal profile] kareila.

Files modified:
  • cgi-bin/LJ/Entry.pm
  • cgi-bin/LJ/Lang.pm
  • cgi-bin/LJ/Message.pm
  • cgi-bin/LJ/S2.pm
  • cgi-bin/LJ/S2/RecentPage.pm
  • cgi-bin/LJ/S2Theme.pm
  • cgi-bin/LJ/Setting/ImagePlaceholders.pm
  • cgi-bin/LJ/Talk.pm
  • cgi-bin/LJ/User.pm
  • cgi-bin/LJ/Widget.pm
  • cgi-bin/LJ/Widget/CreateAccountTheme.pm
  • cgi-bin/LJ/Widget/Location.pm
  • cgi-bin/LJ/Widget/S2PropGroup.pm
  • cgi-bin/LJ/Widget/ShopCart.pm
  • cgi-bin/htmlcontrols.pl
  • cgi-bin/ljemailgateway.pl
  • cgi-bin/weblib.pl
--------------------------------------------------------------------------------
diff -r e4a5fc6f26b1 -r 9d643eb74e56 cgi-bin/LJ/Entry.pm
--- a/cgi-bin/LJ/Entry.pm	Thu Jan 21 13:22:38 2010 +0000
+++ b/cgi-bin/LJ/Entry.pm	Thu Jan 21 13:38:39 2010 +0000
@@ -1963,7 +1963,7 @@ sub reject_entry_as_spam {
         undef, $journalu->{'userid'}, $modid);
 
     use Storable;
-    my $req = Storable::thaw($frozen) if $frozen;
+    my $req = $frozen ? Storable::thaw($frozen) : undef;
 
     my ($subject, $body) = ($req->{subject}, $req->{event});
     return 0 unless $body;
diff -r e4a5fc6f26b1 -r 9d643eb74e56 cgi-bin/LJ/Lang.pm
--- a/cgi-bin/LJ/Lang.pm	Thu Jan 21 13:22:38 2010 +0000
+++ b/cgi-bin/LJ/Lang.pm	Thu Jan 21 13:38:39 2010 +0000
@@ -636,7 +636,7 @@ sub get_text_multi
     my %memkeys; 
     foreach my $code (keys %lc_codes) {
         my $cache_key = "ml.${lang}.${dmid}.${code}";
-        my $text = $TXT_CACHE{$cache_key} unless $LJ::NO_ML_CACHE;
+        my $text = $LJ::NO_ML_CACHE ? undef : $TXT_CACHE{$cache_key};
         
         if (defined $text) {
             $strings{ $lc_codes{$code} } = $text;
diff -r e4a5fc6f26b1 -r 9d643eb74e56 cgi-bin/LJ/Message.pm
--- a/cgi-bin/LJ/Message.pm	Thu Jan 21 13:22:38 2010 +0000
+++ b/cgi-bin/LJ/Message.pm	Thu Jan 21 13:38:39 2010 +0000
@@ -97,8 +97,10 @@ sub save_to_db {
     my $same_cluster = $orig_u->clusterid eq $rcpt_u->clusterid;
 
     # Begin DB Transaction
-    my $o_rv = $orig_u->begin_work;
-    my $r_rv = $rcpt_u->begin_work unless $same_cluster;
+    my ( $o_rv, $r_rv );
+    $o_rv = $orig_u->begin_work;
+    $r_rv = $rcpt_u->begin_work
+        unless $same_cluster;
 
     # Write to DB
     my $rcpt_write = $self->_save_recipient_message;
diff -r e4a5fc6f26b1 -r 9d643eb74e56 cgi-bin/LJ/S2.pm
--- a/cgi-bin/LJ/S2.pm	Thu Jan 21 13:22:38 2010 +0000
+++ b/cgi-bin/LJ/S2.pm	Thu Jan 21 13:38:39 2010 +0000
@@ -1969,7 +1969,8 @@ sub Entry_from_entryobj
     # comment information
     my $permalink = $entry_obj->url;
     my $replycount = $entry_obj->reply_count;
-    my $nc = "nc=$replycount" if $replycount && $remote && $remote->prop( 'opt_nctalklinks' );
+    my $nc;
+    $nc = "nc=$replycount" if $replycount && $remote && $remote->prop( 'opt_nctalklinks' );
     my $readurl = LJ::Talk::talkargs( $permalink, $nc, $style_args );
     my $posturl = LJ::Talk::talkargs( $permalink, 'mode=reply', $style_args );
 
diff -r e4a5fc6f26b1 -r 9d643eb74e56 cgi-bin/LJ/S2/RecentPage.pm
--- a/cgi-bin/LJ/S2/RecentPage.pm	Thu Jan 21 13:22:38 2010 +0000
+++ b/cgi-bin/LJ/S2/RecentPage.pm	Thu Jan 21 13:38:39 2010 +0000
@@ -120,7 +120,8 @@ sub RecentPage
 
     # prepare sticky entry for S2 - only show sticky entry on first page of Recent Entries, not on skip= pages
     # or tag and security subfilters
-    my $stickyentry = $u->get_sticky_entry
+    my $stickyentry;
+    $stickyentry = $u->get_sticky_entry
         if $skip == 0 && ! $opts->{securityfilter} && ! $opts->{tagids};
     # only show if visible to user
     if ( $stickyentry && $stickyentry->visible_to( $remote, $get->{viewall} ) ) {
diff -r e4a5fc6f26b1 -r 9d643eb74e56 cgi-bin/LJ/S2Theme.pm
--- a/cgi-bin/LJ/S2Theme.pm	Thu Jan 21 13:22:38 2010 +0000
+++ b/cgi-bin/LJ/S2Theme.pm	Thu Jan 21 13:38:39 2010 +0000
@@ -598,7 +598,7 @@ sub get_preview_styleid {
 
     # get the styleid of the _for_preview style
     my $styleid = $u->prop('theme_preview_styleid');
-    my $style = LJ::S2::load_style($styleid) if $styleid;
+    my $style = $styleid ? LJ::S2::load_style( $styleid ) : undef;
     if (!$styleid || !$style) {
         $styleid = LJ::S2::create_style($u, "_for_preview");
         $u->set_prop('theme_preview_styleid', $styleid);
diff -r e4a5fc6f26b1 -r 9d643eb74e56 cgi-bin/LJ/Setting/ImagePlaceholders.pm
--- a/cgi-bin/LJ/Setting/ImagePlaceholders.pm	Thu Jan 21 13:22:38 2010 +0000
+++ b/cgi-bin/LJ/Setting/ImagePlaceholders.pm	Thu Jan 21 13:38:39 2010 +0000
@@ -51,7 +51,8 @@ sub option {
         "0|0" => 1,
         "" => 1,
     }->{$imgplaceholders};
-    my $extra = $class->ml('setting.imageplaceholders.option.select.custom', { width => $maxwidth, height => $maxheight })
+    my $extra;
+    $extra = $class->ml('setting.imageplaceholders.option.select.custom', { width => $maxwidth, height => $maxheight })
         unless $is_stock;
 
     my @options = (
diff -r e4a5fc6f26b1 -r 9d643eb74e56 cgi-bin/LJ/Talk.pm
--- a/cgi-bin/LJ/Talk.pm	Thu Jan 21 13:22:38 2010 +0000
+++ b/cgi-bin/LJ/Talk.pm	Thu Jan 21 13:38:39 2010 +0000
@@ -1382,7 +1382,7 @@ sub talkform {
             }
     
             # URL: [    ]  Verify? [ ]
-            my $url_def = $form->{'oidurl'} || $oid_identity if defined $oid_identity;
+            my $url_def = defined $oid_identity ? $form->{'oidurl'} || $oid_identity : "";
 
             $ret .= "<tr valign='middle' align='left' id='oid_more'><td colspan='2'></td><td>";
             $ret .= "Identity URL:&nbsp;<input class='textbox' name='oidurl' maxlength='60' size='53' id='oidurl' value='$url_def' /> ";
@@ -1482,7 +1482,7 @@ sub talkform {
             }
 
             # URL: [    ]  Verify? [ ]
-            my $url_def = $form->{'oidurl'} || $oid_identity if defined $oid_identity;
+            my $url_def = defined $oid_identity ? $form->{'oidurl'} || $oid_identity : "";
 
             $ret .= "<tr valign='middle' align='left' id='oid_more'><td colspan='2'></td><td>";
             $ret .= "Identity URL:&nbsp;<input class='textbox' name='oidurl' maxlength='60' size='53' id='oidurl' value='$url_def' /> ";
diff -r e4a5fc6f26b1 -r 9d643eb74e56 cgi-bin/LJ/User.pm
--- a/cgi-bin/LJ/User.pm	Thu Jan 21 13:22:38 2010 +0000
+++ b/cgi-bin/LJ/User.pm	Thu Jan 21 13:38:39 2010 +0000
@@ -5881,7 +5881,7 @@ sub load_user_or_identity {
     {
         # overload the uidof memcache key to accept both display name and name
         my $uid = LJ::MemCache::get( "uidof:$url" );
-        my $u = LJ::memcache_get_u( [ $uid, "userid:$uid" ] ) if $uid;
+        my $u = $uid ? LJ::memcache_get_u( [ $uid, "userid:$uid" ] ) : undef;
         return _set_u_req_cache( $u ) if $u;
     }
 
@@ -5889,7 +5889,7 @@ sub load_user_or_identity {
     my $uid = $dbh->selectrow_array("SELECT userid FROM identitymap WHERE idtype=? AND identity=?",
                                     undef, 'O', $url);
 
-    my $u = LJ::load_userid($uid) if $uid;
+    my $u = $uid ? LJ::load_userid($uid) : undef;
 
     # set user in memcache
     if ( $u ) {
@@ -8009,7 +8009,7 @@ sub get_daycounts
     if ($remote) {
         # do they have the viewall priv?
         my $r = eval { Apache->request; }; # web context
-        my %getargs = $r->args if $r;
+        my %getargs = $r ? $r->args : undef;
         if ( defined $getargs{'viewall'} and $getargs{'viewall'} eq '1' and ( $remote && $remote->has_priv( 'canview', '*' ) ) ) {
             $viewall = 1;
             LJ::statushistory_add( $u->userid, $remote->userid,
diff -r e4a5fc6f26b1 -r 9d643eb74e56 cgi-bin/LJ/Widget.pm
--- a/cgi-bin/LJ/Widget.pm	Thu Jan 21 13:22:38 2010 +0000
+++ b/cgi-bin/LJ/Widget.pm	Thu Jan 21 13:38:39 2010 +0000
@@ -64,7 +64,7 @@ sub start_form {
     if ($class->authas) {
         my $u = $opts{authas} || $BMLCodeBlock::GET{authas} || $BMLCodeBlock::POST{authas};
         $u = LJ::load_user($u) unless LJ::isu($u);
-        my $authas = $u->user if LJ::isu($u);
+        my $authas = LJ::isu($u) ? $u->user : undef;
 
         if ($authas && !$LJ::REQ_GLOBAL{widget_authas_form}) {
             $ret .= $class->html_hidden({ name => "authas", value => $authas, id => "_widget_authas" });
diff -r e4a5fc6f26b1 -r 9d643eb74e56 cgi-bin/LJ/Widget/CreateAccountTheme.pm
--- a/cgi-bin/LJ/Widget/CreateAccountTheme.pm	Thu Jan 21 13:22:38 2010 +0000
+++ b/cgi-bin/LJ/Widget/CreateAccountTheme.pm	Thu Jan 21 13:38:39 2010 +0000
@@ -39,7 +39,8 @@ sub render_body {
         $image_class =~ s/\//_/;
         my $name = $theme->name . ", " . $theme->layout_name;
 
-        my @checked = ( checked => "checked" ) if $current_theme->uniq eq $uniq;
+        my @checked;
+        @checked = ( checked => "checked" ) if $current_theme->uniq eq $uniq;
 
         $ret .= "<tr>" if $count % 3 == 0;
         $ret .= "<td class='theme-box'>";
diff -r e4a5fc6f26b1 -r 9d643eb74e56 cgi-bin/LJ/Widget/Location.pm
--- a/cgi-bin/LJ/Widget/Location.pm	Thu Jan 21 13:22:38 2010 +0000
+++ b/cgi-bin/LJ/Widget/Location.pm	Thu Jan 21 13:38:39 2010 +0000
@@ -57,8 +57,7 @@ sub render_body {
     # check if specified country has regions
     my $regions_cfg = $class->country_regions_cfg($effective_country);
     # hashref of all regions for the specified country; it is initialized and used only if $regions_cfg is defined, i.e. the country has regions (states)
-    my $state_options = $class->region_options($regions_cfg)
-        if $regions_cfg;
+    my $state_options = $regions_cfg ? $class->region_options($regions_cfg) : undef;
 
 
     my $state_inline_desc = $class->ml('widget.location.fn.state.inline');
@@ -235,7 +234,8 @@ sub handle_post {
     $post->{zip} = "" if $post->{zip} eq $zip_inline_desc;
 
     # state and zip
-    my ($zipcity, $zipstate) = LJ::load_state_city_for_zip($post->{'zip'})
+    my ( $zipcity, $zipstate );
+    ( $zipcity, $zipstate ) = LJ::load_state_city_for_zip( $post->{'zip'} )
         if $post->{'country'} eq "US" && length $post->{'zip'} > 0;
 
     # country
diff -r e4a5fc6f26b1 -r 9d643eb74e56 cgi-bin/LJ/Widget/S2PropGroup.pm
--- a/cgi-bin/LJ/Widget/S2PropGroup.pm	Thu Jan 21 13:22:38 2010 +0000
+++ b/cgi-bin/LJ/Widget/S2PropGroup.pm	Thu Jan 21 13:38:39 2010 +0000
@@ -131,7 +131,8 @@ sub render_body {
                 next if $class->skip_prop( $props->{$prop_name}, $prop_name, theme => $theme, user => $u, style => $style );
 
                 unless ($header_printed) {
-                    my $prop_list_class = " first" if $subheader_counter == 1;
+                    my $prop_list_class;
+                    $prop_list_class = " first" if $subheader_counter == 1;
 
                     $ret .= "<div class='subheader subheader-modules on' id='subheader__modules__${subheader}'>$subheaders{$subheader}</div>";
                     $ret .= "<table cellspacing='0' class='prop-list$prop_list_class' id='proplist__modules__${subheader}'>";
@@ -181,7 +182,8 @@ sub render_body {
                 # need to print the header inside the foreach because we don't want it printed if
                 # there's no props in this group that are also in this subheader
                 unless ($header_printed) {
-                    my $prop_list_class = " first" if $subheader_counter == 1;
+                    my $prop_list_class;
+                    $prop_list_class = " first" if $subheader_counter == 1;
 
                     $ret .= "<div class='subheader subheader-$propgroup on' id='subheader__${propgroup}__${subheader}'>$subheaders{$subheader}</div>";
                     $ret .= "<table cellspacing='0' class='prop-list$prop_list_class' id='proplist__${propgroup}__${subheader}'>";
diff -r e4a5fc6f26b1 -r 9d643eb74e56 cgi-bin/LJ/Widget/ShopCart.pm
--- a/cgi-bin/LJ/Widget/ShopCart.pm	Thu Jan 21 13:22:38 2010 +0000
+++ b/cgi-bin/LJ/Widget/ShopCart.pm	Thu Jan 21 13:38:39 2010 +0000
@@ -106,7 +106,8 @@ sub render_body {
         $ret .= "<p>" . $class->html_submit( removeselected => $class->ml( 'widget.shopcart.btn.removeselected' ) ) . " ";
         $ret .= $class->html_submit( discard => $class->ml( 'widget.shopcart.btn.discard' ) ) . "</p>";
 
-        my @paypal_option = (
+        my @paypal_option;
+        @paypal_option = (
             paypal => $class->ml( 'widget.shopcart.paymentmethod.paypal' ),
             creditcardpp => $class->ml( 'widget.shopcart.paymentmethod.creditcardpp' ),
         )
diff -r e4a5fc6f26b1 -r 9d643eb74e56 cgi-bin/htmlcontrols.pl
--- a/cgi-bin/htmlcontrols.pl	Thu Jan 21 13:22:38 2010 +0000
+++ b/cgi-bin/htmlcontrols.pl	Thu Jan 21 13:38:39 2010 +0000
@@ -166,7 +166,8 @@ sub html_select
     $ret .= ">\n";
 
     # build hashref from arrayref if multiple selected
-    my $selref = { map { $_, 1 } @{$opts->{'selected'}} }
+    my $selref;
+    $selref = { map { $_, 1 } @{$opts->{'selected'}} }
         if $opts->{'multiple'} && ref $opts->{'selected'} eq 'ARRAY';
 
     my $did_sel = 0;
diff -r e4a5fc6f26b1 -r 9d643eb74e56 cgi-bin/ljemailgateway.pl
--- a/cgi-bin/ljemailgateway.pl	Thu Jan 21 13:22:38 2010 +0000
+++ b/cgi-bin/ljemailgateway.pl	Thu Jan 21 13:38:39 2010 +0000
@@ -133,7 +133,8 @@ sub process {
     my $content_type = $tent->head->get('Content-type:');
     $charset = $1 if $content_type =~ /\bcharset=['\"]?(\S+?)['\"]?[\s\;]/i;
     $format = $1 if $content_type =~ /\bformat=['\"]?(\S+?)['\"]?[\s\;]/i;
-    my $delsp = $1 if $content_type =~ /\bdelsp=['\"]?(\w+?)['\"]?[\s\;]/i;
+    my $delsp;
+    $delsp = $1 if $content_type =~ /\bdelsp=['\"]?(\w+?)['\"]?[\s\;]/i;
 
     if (defined($charset) && $charset !~ /^UTF-?8$/i) { # no charset? assume us-ascii
         return $err->("Unknown charset encoding type. ($charset)")
@@ -212,7 +213,8 @@ sub process {
 
         # ok, parse the XML.
         my $html = $tent->bodyhandle->as_string();
-        my $xml_string = $1 if $html =~ /<!-- lsPictureMail-Share-\w+-comment\n(.+)\n-->/is;
+        my $xml_string;
+        $xml_string = $1 if $html =~ /<!-- lsPictureMail-Share-\w+-comment\n(.+)\n-->/is;
         return $err->(
             "Unable to find XML content in PictureMail message.",
           ) unless $xml_string;
diff -r e4a5fc6f26b1 -r 9d643eb74e56 cgi-bin/weblib.pl
--- a/cgi-bin/weblib.pl	Thu Jan 21 13:22:38 2010 +0000
+++ b/cgi-bin/weblib.pl	Thu Jan 21 13:38:39 2010 +0000
@@ -955,14 +955,16 @@ sub make_qr_link
 # </LJFUNC>
 sub get_lastcomment {
     my $remote = LJ::get_remote();
-    return (undef, undef) unless $remote;
+    my ( $talkid, $jid );
 
     # Figure out their last post
-    my $memkey = [$remote->{'userid'}, "lastcomm:$remote->{'userid'}"];
-    my $memval = LJ::MemCache::get($memkey);
-    my ($jid, $talkid) = split(/:/, $memval) if $memval;
+    if ( $remote ) {
+        my $memkey = [$remote->{'userid'}, "lastcomm:$remote->{'userid'}"];
+        my $memval = LJ::MemCache::get( $memkey );
+        ( $jid, $talkid ) = split( /:/, $memval ) if $memval;
+    }
 
-    return ($talkid, $jid);
+    return ( $talkid, $jid );
 }
 
 # <LJFUNC>
@@ -3718,7 +3720,8 @@ sub statusvis_message_js {
 
     return "" unless $u->is_locked || $u->is_memorial || $u->is_readonly;
 
-    my $statusvis_full = "locked" if $u->is_locked;
+    my $statusvis_full;
+    $statusvis_full = "locked"   if $u->is_locked;
     $statusvis_full = "memorial" if $u->is_memorial;
     $statusvis_full = "readonly" if $u->is_readonly;
 
--------------------------------------------------------------------------------

Post a comment in response:

This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

If you are unable to use this captcha for any reason, please contact us by email at support@dreamwidth.org