[dw-free] Prohibit Conditional Declarations (backend cleanup)
[commit: http://hg.dwscoalition.org/dw-free/rev/a07ddfd51cfa]
http://bugs.dwscoalition.org/show_bug.cgi?id=2270
Avoid potential pitfall: nested htdocs.
Patch by
kareila.
Files modified:
http://bugs.dwscoalition.org/show_bug.cgi?id=2270
Avoid potential pitfall: nested htdocs.
Patch by
Files modified:
- htdocs/admin/invitecodes.bml
- htdocs/admin/statushistory.bml
- htdocs/community/join.bml
- htdocs/community/members.bml
- htdocs/community/moderate.bml
- htdocs/community/sentinvites.bml
- htdocs/customize/advanced/layeredit.bml
- htdocs/customize/advanced/layers.bml
- htdocs/manage/pubkey.bml
- htdocs/manage/settings/index.bml
- htdocs/misc/latestqotd.bml
- htdocs/preview/entry.bml
- htdocs/settings/index.bml
- htdocs/support/faqbrowse.bml
- htdocs/support/history.bml
- htdocs/support/see_request.bml
--------------------------------------------------------------------------------
diff -r 9d643eb74e56 -r a07ddfd51cfa htdocs/admin/invitecodes.bml
--- a/htdocs/admin/invitecodes.bml Thu Jan 21 13:38:39 2010 +0000
+++ b/htdocs/admin/invitecodes.bml Thu Jan 21 15:07:31 2010 +0000
@@ -61,7 +61,7 @@ sub display_codes {
foreach my $code ( @codes ) {
my $owner = $code->owner == $account->id ? $account : LJ::load_userid( $code->owner );
- my $recipient = LJ::load_userid( $code->recipient ) if $code->is_used;
+ my $recipient = $code->is_used ? LJ::load_userid( $code->recipient ) : undef;
$ret .= "<tr>";
$ret .= "<td><tt>" . $code->code . "</tt></td>";
$ret .= "<td>" . ( $owner ? $owner->ljuser_display : "" ) . "</td>";
diff -r 9d643eb74e56 -r a07ddfd51cfa htdocs/admin/statushistory.bml
--- a/htdocs/admin/statushistory.bml Thu Jan 21 13:38:39 2010 +0000
+++ b/htdocs/admin/statushistory.bml Thu Jan 21 15:07:31 2010 +0000
@@ -51,7 +51,8 @@
push @where, "s.shtype=$qt";
}
- my $where = "WHERE " . join(" AND ", @where) . " " if @where;
+ my $where = "";
+ $where = "WHERE " . join(" AND ", @where) . " " if @where;
my $orderby = 'shdate';
foreach (qw(user admin shdate shtype notes)) {
diff -r 9d643eb74e56 -r a07ddfd51cfa htdocs/community/join.bml
--- a/htdocs/community/join.bml Thu Jan 21 13:38:39 2010 +0000
+++ b/htdocs/community/join.bml Thu Jan 21 15:07:31 2010 +0000
@@ -118,10 +118,12 @@ body<=
# success message -- only shows if user didn't add the community as a friend
my $profile_url = $cu->profile_url;
my $show_join_post_link = $cu->hide_join_post_link ? 0 : 1;
- my $post_url = $LJ::SITEROOT . "/update?usejournal=" . $cu->user
+ my $post_url;
+ $post_url = $LJ::SITEROOT . "/update?usejournal=" . $cu->user
if $show_join_post_link && $remote->can_post_to( $cu );
my $posting_guidelines_entry = $cu->get_posting_guidelines_entry;
- my $posting_guidelines_entry_url = $posting_guidelines_entry->url
+ my $posting_guidelines_entry_url;
+ $posting_guidelines_entry_url = $posting_guidelines_entry->url
if $posting_guidelines_entry;
$ret .= "<?h1 $ML{'.success'} h1?><?p " . BML::ml('.label.membernow6',
diff -r 9d643eb74e56 -r a07ddfd51cfa htdocs/community/members.bml
--- a/htdocs/community/members.bml Thu Jan 21 13:38:39 2010 +0000
+++ b/htdocs/community/members.bml Thu Jan 21 15:07:31 2010 +0000
@@ -502,7 +502,7 @@ body<=
# how to make links back to this page
my $self_link = sub {
- my $sort = "&sort=$GET{'sort'}" if $GET{'sort'};
+ my $sort = $GET{'sort'} ? "&sort=$GET{'sort'}" : "";
return "members?authas=$cname&page=$_[0]$sort";
};
diff -r 9d643eb74e56 -r a07ddfd51cfa htdocs/community/moderate.bml
--- a/htdocs/community/moderate.bml Thu Jan 21 13:38:39 2010 +0000
+++ b/htdocs/community/moderate.bml Thu Jan 21 15:07:31 2010 +0000
@@ -59,7 +59,7 @@ body<=
my $frozen = $dbcm->selectrow_array("SELECT request_stor FROM modblob WHERE journalid=? AND modid=?",
undef, $c->{'userid'}, $modid);
- my $req = Storable::thaw($frozen) if $frozen;
+ my $req = $frozen ? Storable::thaw($frozen) : undef;
unless ($frozen && $entry && $req->{'_moderate'}->{'authcode'} && $req->{'_moderate'}->{'authcode'} eq $POST{'auth'}) {
$ret .= "<?h1 $ML{'Error'} h1?><?p $ML{'.error.noentry'} p?>";
return $ret;
diff -r 9d643eb74e56 -r a07ddfd51cfa htdocs/community/sentinvites.bml
--- a/htdocs/community/sentinvites.bml Thu Jan 21 13:38:39 2010 +0000
+++ b/htdocs/community/sentinvites.bml Thu Jan 21 15:07:31 2010 +0000
@@ -147,8 +147,9 @@ body<=
# how to make links back to this page
my $self_link = sub {
- my $sort = "&sort=$GET{'sort'}" if $GET{'sort'};
- my $filter = "&show=$GET{'show'}" if $GET{'show'};
+ my ( $sort, $filter ) = ( "", "" );
+ $sort = "&sort=$GET{'sort'}" if $GET{'sort'};
+ $filter = "&show=$GET{'show'}" if $GET{'show'};
return "sentinvites?authas=$cname&page=$_[0]$sort$filter";
};
@@ -178,7 +179,7 @@ body<=
$showlinks .= LJ::html_submit( undef, $ML{'.filterto.btn.refresh'} );
$showlinks .= "</form>";
- my $filter = "&show=$GET{show}" if $GET{show};
+ my $filter = $GET{show} ? "&show=$GET{show}" : "";
my $sortlink = BML::get_uri() . "?authas=$cname$filter&sort=";
$ret .= "<br /><div align='center'>$showlinks";
$ret .= <<END;
diff -r 9d643eb74e56 -r a07ddfd51cfa htdocs/customize/advanced/layeredit.bml
--- a/htdocs/customize/advanced/layeredit.bml Thu Jan 21 13:38:39 2010 +0000
+++ b/htdocs/customize/advanced/layeredit.bml Thu Jan 21 15:07:31 2010 +0000
@@ -9,7 +9,8 @@
};
# we need a valid id
- my $id = $GET{'id'} if $GET{'id'} =~ /^\d+$/;
+ my $id;
+ $id = $GET{'id'} if $GET{'id'} =~ /^\d+$/;
return $err->("You have not specified a layer to edit.")
unless $id;
diff -r 9d643eb74e56 -r a07ddfd51cfa htdocs/customize/advanced/layers.bml
--- a/htdocs/customize/advanced/layers.bml Thu Jan 21 13:38:39 2010 +0000
+++ b/htdocs/customize/advanced/layers.bml Thu Jan 21 15:07:31 2010 +0000
@@ -28,7 +28,8 @@
};
# id is optional
- my $id = $POST{'id'} if $POST{'id'} =~ /^\d+$/;
+ my $id;
+ $id = $POST{'id'} if $POST{'id'} =~ /^\d+$/;
# this catches core_hidden if it's set
$POST{'parid'} ||= $POST{'parid_hidden'};
diff -r 9d643eb74e56 -r a07ddfd51cfa htdocs/manage/pubkey.bml
--- a/htdocs/manage/pubkey.bml Thu Jan 21 13:38:39 2010 +0000
+++ b/htdocs/manage/pubkey.bml Thu Jan 21 15:07:31 2010 +0000
@@ -22,12 +22,14 @@ body<=
# make sure it is a public key, not a private or a signature,
# before we bother with other checks
- my $kt = $1 if $key =~ /-{5}BEGIN PGP (\w+) /;
+ my $kt;
+ $kt = $1 if $key =~ /-{5}BEGIN PGP (\w+) /;
return 0 unless $kt eq 'PUBLIC';
# pull key data, return if suspicious
my $ks = "$kt KEY BLOCK";
- my $data = $1 if $key =~ /$ks-{5}(.+?)-{5}.+?$ks(?:-)+/s;
+ my $data;
+ $data = $1 if $key =~ /$ks-{5}(.+?)-{5}.+?$ks(?:-)+/s;
foreach ($data =~ /^(\w+):/mg) {
return 0 unless $1 =~ /(Version|Hash|Comment|MessageID|Charset)/i;
}
diff -r 9d643eb74e56 -r a07ddfd51cfa htdocs/manage/settings/index.bml
--- a/htdocs/manage/settings/index.bml Thu Jan 21 13:38:39 2010 +0000
+++ b/htdocs/manage/settings/index.bml Thu Jan 21 15:07:31 2010 +0000
@@ -381,7 +381,7 @@ body<=
if ($cats_with_settings{$cat}->{disabled}) {
$ret .= "<li class='disabled'>$cats_with_settings{$cat}->{name}</li>";
} else {
- my $active_class = " class='active'" if $cat eq $given_cat;
+ my $active_class = $cat eq $given_cat ? " class='active'" : "";
$ret .= "<li><a href='$LJ::SITEROOT/manage/settings/$getextra${getsep}cat=$cat'$active_class>$cats_with_settings{$cat}->{name}</a></li>";
}
}
diff -r 9d643eb74e56 -r a07ddfd51cfa htdocs/misc/latestqotd.bml
--- a/htdocs/misc/latestqotd.bml Thu Jan 21 13:38:39 2010 +0000
+++ b/htdocs/misc/latestqotd.bml Thu Jan 21 15:07:31 2010 +0000
@@ -12,7 +12,7 @@ body<=
my $ret;
my $qid = $GET{qid}+0;
- my $qotd = LJ::QotD->get_single_question($qid) if $qid;
+ my $qotd = $qid ? LJ::QotD->get_single_question($qid) : undef;
$ret .= "<table width='100%' cellspacing='5' cellpadding='0'><tr><td valign='top'>";
$ret .= LJ::Widget::QotDResponses->render;
diff -r 9d643eb74e56 -r a07ddfd51cfa htdocs/preview/entry.bml
--- a/htdocs/preview/entry.bml Thu Jan 21 13:38:39 2010 +0000
+++ b/htdocs/preview/entry.bml Thu Jan 21 15:07:31 2010 +0000
@@ -61,7 +61,8 @@
# check whether to use custom comment pages
$ctx = LJ::S2::s2_context( $u->{s2_style} );
- my $view_entry_disabled = ! $ctx->[S2::PROPS]->{use_journalstyle_entry_page} if $ctx;
+ my $view_entry_disabled;
+ $view_entry_disabled = ! $ctx->[S2::PROPS]->{use_journalstyle_entry_page} if $ctx;
return (2, $u->{'s2_style'}) unless $forceflag || $view_entry_disabled;
}
diff -r 9d643eb74e56 -r a07ddfd51cfa htdocs/settings/index.bml
--- a/htdocs/settings/index.bml Thu Jan 21 13:38:39 2010 +0000
+++ b/htdocs/settings/index.bml Thu Jan 21 15:07:31 2010 +0000
@@ -68,7 +68,8 @@
return;
}
- my $returns = LJ::Setting::save_all($u, \%POST, \@matches)
+ my $returns;
+ $returns = LJ::Setting::save_all( $u, \%POST, \@matches )
if LJ::did_post();
$body .= "<form method='get' action='./'>\n";
diff -r 9d643eb74e56 -r a07ddfd51cfa htdocs/support/faqbrowse.bml
--- a/htdocs/support/faqbrowse.bml Thu Jan 21 13:38:39 2010 +0000
+++ b/htdocs/support/faqbrowse.bml Thu Jan 21 15:07:31 2010 +0000
@@ -193,7 +193,7 @@ body<=
$$body .= "<br />";
unless ( $display_answer ) {
- my $q = "&q=" . LJ::eurl($qterm) if $qterm;
+ my $q = $qterm ? "&q=" . LJ::eurl($qterm) : "";
$$body .= "<div id='rm' name='rm'>";
my $oc = $faqcatarg ? '' : "onclick='return showAnswer();'";
diff -r 9d643eb74e56 -r a07ddfd51cfa htdocs/support/history.bml
--- a/htdocs/support/history.bml Thu Jan 21 13:38:39 2010 +0000
+++ b/htdocs/support/history.bml Thu Jan 21 15:07:31 2010 +0000
@@ -67,7 +67,7 @@ body<=
};
push @userids, $row->[4] if $row->[4];
}
- my $us = LJ::load_userids(@userids) if @userids;
+ my $us = @userids ? LJ::load_userids(@userids) : undef;
# get categories
my $cats = LJ::Support::load_cats();
diff -r 9d643eb74e56 -r a07ddfd51cfa htdocs/support/see_request.bml
--- a/htdocs/support/see_request.bml Thu Jan 21 13:38:39 2010 +0000
+++ b/htdocs/support/see_request.bml Thu Jan 21 15:07:31 2010 +0000
@@ -335,7 +335,7 @@ body<=
"$ename <a href=\"history?user=$u->{user}\">" . LJ::ehtml($u->{name}) . "</a>" :
"$ename";
- my $email_string = " ($visemail)" if $has_vs || $has_sh;
+ my $email_string = $has_vs || $has_sh ? " ($visemail)" : "";
$email_string = " (<a href=\"history?email=" . LJ::eurl($email) . "\">$email</a>)" if $show_history{email};
$ret .= $email_string;
} else {
--------------------------------------------------------------------------------
