fu: Close-up of Fu, bringing a scoop of water to her mouth (Default)
fu ([personal profile] fu) wrote in [site community profile] changelog2011-10-31 07:54 am

[dw-free] Using a certain username in a user tag breaks Dreamwidth

[commit: http://hg.dwscoalition.org/dw-free/rev/10b29c8c082c]

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

Shortcircuit if we redirect to a user which is no longer valid.

Patch by [personal profile] fu.

Files modified:
  • cgi-bin/LJ/User.pm
--------------------------------------------------------------------------------
diff -r 63e3af5ee420 -r 10b29c8c082c cgi-bin/LJ/User.pm
--- a/cgi-bin/LJ/User.pm	Mon Oct 31 13:23:18 2011 +0800
+++ b/cgi-bin/LJ/User.pm	Mon Oct 31 15:55:07 2011 +0800
@@ -1019,17 +1019,25 @@
     my $u = shift;
     my %opts = @_;
     my $hops = $opts{hops} || 5;
+    my $username;
 
     # Traverse the renames to the final journal
     if ($u) {
         while ( $u->is_redirect && $hops-- > 0 ) {
             my $rt = $u->prop("renamedto");
             last unless length $rt;
-            $u = LJ::load_user($rt);
+
+            $username = $rt;
+            $u = LJ::load_user( $rt );
+
+            # the username we renamed to is no longer a valid user
+            last unless LJ::isu( $u );
         }
     }
 
-    return $u;
+    # return both the user object, and the last known renamedto username
+    # in case the user object isn't valid
+    return ( $u, $username );
 }
 
 
@@ -8456,7 +8464,7 @@
 
     # Traverse the renames to the final journal
     if ($u && !$opts->{'no_follow'}) {
-        $u = $u->get_renamed_user;
+        ( $u, $user ) = $u->get_renamed_user;
     }
 
     # if invalid user, link to dummy userinfo page
--------------------------------------------------------------------------------

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