More warnings. Less warnings?

        Patch by szabgab. 

diffs (133 lines):

diff -r 6fdc677f6e0f -r 863165dfc54e cgi-bin/LJ/EmbedModule.pm
--- a/cgi-bin/LJ/EmbedModule.pm Fri Sep 11 13:44:33 2009 +0000
+++ b/cgi-bin/LJ/EmbedModule.pm Fri Sep 11 13:47:03 2009 +0000
@@ -194,7 +194,7 @@ sub parse_module_embed {
 
         # we decided to switch back to REGULAR and have something in embed 
buffer
         # so let's save buffer as an embed module and start all over again
-        if ($newstate == REGULAR && $embed) {
+        if (defined $newstate && $newstate == REGULAR && $embed) {
             $embed_attrs{id} = $class->save_module(
                 id => ($preview ? $next_preview_id++ : $embed_attrs{id}),
                 contents => $embed,
diff -r 6fdc677f6e0f -r 863165dfc54e cgi-bin/LJ/Userpic.pm
--- a/cgi-bin/LJ/Userpic.pm     Fri Sep 11 13:44:33 2009 +0000
+++ b/cgi-bin/LJ/Userpic.pm     Fri Sep 11 13:47:03 2009 +0000
@@ -151,7 +151,8 @@ sub absorb_row {
     for my $f (qw(userid picid width height comment description location state 
url pictime flags md5base64)) {
         $self->{$f} = $row->{$f};
     }
-    $self->{_ext} = $MimeTypeMap{$row->{fmt} || $row->{contenttype}};
+    my $key = $row->{fmt} || $row->{contenttype}; # avoid warnings on 
uninitialized value in hash element FIXME
+    $self->{_ext} = $MimeTypeMap{$key} if defined $key;
     return $self;
 }
 
@@ -680,6 +681,7 @@ sub create {
     };
 
     ### insert the blob
+    $target ||= ''; # avoid warnings FIXME should this be set before the 
INSERT call?
     if ($target eq 'mogile' && !$dberr) {
         my $fh = LJ::mogclient()->new_file($u->mogfs_userpic_key($picid), 
'userpics');
         if (defined $fh) {
@@ -801,7 +803,8 @@ sub delete {
     # TODO: we could fire warnings if they fail, then if $LJ::DIE_ON_WARN is 
set,
     # the ->warn methods on errobjs are actually dies.
     eval {
-        if ($self->location eq 'mogile') {
+        my $location = $self->location; # avoid warnings FIXME
+        if (defined $location and $location eq 'mogile') {
             LJ::mogclient()->delete($u->mogfs_userpic_key($picid));
         } elsif ($LJ::USERPIC_BLOBSERVER &&
                  LJ::Blob::delete($u, "userpic", $self->extension, $picid)) {
diff -r 6fdc677f6e0f -r 863165dfc54e cgi-bin/cleanhtml.pl
--- a/cgi-bin/cleanhtml.pl      Fri Sep 11 13:44:33 2009 +0000
+++ b/cgi-bin/cleanhtml.pl      Fri Sep 11 13:47:03 2009 +0000
@@ -368,7 +368,7 @@ sub clean
             # because IE understands them.
             $tag =~ s!/.+$!!;
 
-            if ($action{$tag} eq "eat") {
+            if (defined $action{$tag} and $action{$tag} eq "eat") {
                 $p->unget_token($token);
                 $p->get_tag("/$tag");
                 next;
@@ -743,10 +743,10 @@ sub clean
                     my $allow;
                     if ($mode eq "allow") {
                         $allow = 1;
-                        if ($action{$tag} eq "deny") { $allow = 0; }
+                        if (defined $action{$tag} and $action{$tag} eq "deny") 
{ $allow = 0; }
                     } else {
                         $allow = 0;
-                        if ($action{$tag} eq "allow") { $allow = 1; }
+                        if (defined $action{$tag} and $action{$tag} eq 
"allow") { $allow = 1; }
                     }
 
                     if ($allow && ! $remove{$tag})
@@ -862,10 +862,10 @@ sub clean
             } else {
                 if ($mode eq "allow") {
                     $allow = 1;
-                    if ($action{$tag} eq "deny") { $allow = 0; }
+                    if (defined $action{$tag} and $action{$tag} eq "deny") { 
$allow = 0; }
                 } else {
                     $allow = 0;
-                    if ($action{$tag} eq "allow") { $allow = 1; }
+                    if (defined $action{$tag} and $action{$tag} eq "allow") { 
$allow = 1; }
                 }
 
                 if ($extractlinks && $tag eq "a") {
diff -r 6fdc677f6e0f -r 863165dfc54e cgi-bin/parsefeed.pl
--- a/cgi-bin/parsefeed.pl      Fri Sep 11 13:44:33 2009 +0000
+++ b/cgi-bin/parsefeed.pl      Fri Sep 11 13:47:03 2009 +0000
@@ -42,7 +42,7 @@ sub parse_feed
     # simple heuristic: Atom feeds will have '<feed' somewhere
     # TODO: maybe store the feed's type on creation in a userprop and not 
guess here
 
-    if ($type eq 'atom' || $content =~ m!\<feed!) {
+    if ( (defined $type && $type eq 'atom') || $content =~ m!\<feed!) {
         # try treating it as an atom feed
         $parser = new XML::Parser(Style=>'Stream', Pkg=>'LJ::ParseFeed::Atom');
         return ("", "failed to create XML parser") unless $parser;
@@ -276,7 +276,7 @@ sub StartTag {
         if ($tag eq 'link') {
             # store 'self' and 'hub' rels, for PubSubHubbub support; but only 
valid
             # for the feed, so make sure $item is undef
-            if ( ! $item && ( $_{rel} eq 'self' || $_{rel} eq 'hub' ) ) {
+            if ( ! $item && $_{rel} && ( $_{rel} eq 'self' || $_{rel} eq 'hub' 
) ) {
                 return err( 'Feed not yet defined' )
                     unless $feed;
 
@@ -288,7 +288,7 @@ sub StartTag {
 
             # ignore links with rel= anything but alternate
             # and treat links as rel=alternate if not explicit
-            unless ($_{'rel'} eq 'alternate' || !$_{'rel'}) {
+            unless (!$_{'rel'} || $_{'rel'} eq 'alternate') {
                 swallow();
                 last TAGS;
             }
diff -r 6fdc677f6e0f -r 863165dfc54e t/cleaner-invalid.t
--- a/t/cleaner-invalid.t       Fri Sep 11 13:44:33 2009 +0000
+++ b/t/cleaner-invalid.t       Fri Sep 11 13:47:03 2009 +0000
@@ -33,10 +33,12 @@ is($clean_post, $u->ljuser_display, "Use
 is($clean_post, $u->ljuser_display, "User tag is fine.");
 
 
-my $u = temp_user();
-$post = "<lj user=\"" . $u->user . "\"> and some text <marquee><font 
size=\"24\"><color=\"FF0000\">blah blah";
-$clean->();
-is($clean_post,
-   $u->ljuser_display . qq { and some text <marquee><font 
size="24"></font></marquee><div class='ljparseerror'>[<b>Error:</b> Irreparable 
invalid markup ('&lt;color=&quot;ff0000&quot;&gt;') in entry.  Owner must fix 
manually.  Raw contents below.]<br /><br /><div style="width: 95%; overflow: 
auto">} . LJ::ehtml($post) . "</div></div>",
-   "Invalid markup with a user tag renders correctly.");
+{
+    my $u = temp_user();
+    $post = "<lj user=\"" . $u->user . "\"> and some text <marquee><font 
size=\"24\"><color=\"FF0000\">blah blah";
+    $clean->();
+    is($clean_post,
+        $u->ljuser_display . qq { and some text <marquee><font 
size="24"></font></marquee><div class='ljparseerror'>[<b>Error:</b> Irreparable 
invalid markup ('&lt;color=&quot;ff0000&quot;&gt;') in entry.  Owner must fix 
manually.  Raw contents below.]<br /><br /><div style="width: 95%; overflow: 
auto">} . LJ::ehtml($post) . "</div></div>",
+        "Invalid markup with a user tag renders correctly.");
+}
 
_______________________________________________
dw-changelog mailing list
[email protected]
http://lists.dwscoalition.org/mailman/listinfo/dw-changelog

Reply via email to