vadvs (vadvs) wrote in changelog,
vadvs
vadvs
changelog

[livejournal] r21434: LJSV-2107: Some users cannot view their ...

Committer: vad
LJSV-2107: Some users cannot view their entries, get 'page not found' message
U   trunk/cgi-bin/Apache/LiveJournal.pm
U   trunk/cgi-bin/LJ/User.pm
Modified: trunk/cgi-bin/Apache/LiveJournal.pm
===================================================================
--- trunk/cgi-bin/Apache/LiveJournal.pm	2012-03-16 11:30:45 UTC (rev 21433)
+++ trunk/cgi-bin/Apache/LiveJournal.pm	2012-03-16 12:04:11 UTC (rev 21434)
@@ -379,6 +379,25 @@
 
     LJ::Request->pnotes( 'original_uri' => LJ::Request->uri );
 
+    ## check that request URL is canonical (i.e. it starts with $u->journal_base)
+    ## if not, construct canonical URL and redirect there
+    ## (redirect cases: old http://community.lj.com/name URL, upper-case URLs, hyphen/underscore in usernames etc)
+    {
+
+        ## warning: $uri from outer scope has stripped <user> part from http://users.livejournal.com/<user> URLs
+        my $uri         = LJ::Request->uri;
+        my $current_url = "http://$host$uri";
+        if ($host =~ m!^(users|community)!){
+            my $u = LJ::User->new_from_url($current_url);
+            my $journal_base = $u->journal_base();
+            my $username = $u->username;
+            if ($username !~ /(^_)|(_$)/){
+                $uri =~ s!^/$username/!/!;
+                return redir("$journal_base$uri$args_wq", LJ::Request::HTTP_MOVED_PERMANENTLY());
+            }
+        }
+    }
+
     # process controller
     # if defined
     if ( my $controller = LJ::Request->notes('controller') ) {
@@ -620,22 +639,6 @@
 
         LJ::Request->notes("journalid" => $u->{userid});
 
-        ## check that request URL is canonical (i.e. it starts with $u->journal_base)
-        ## if not, construct canonical URL and redirect there
-        ## (redirect cases: old http://community.lj.com/name URL, upper-case URLs, hyphen/underscore in usernames etc)
-        {
-            ## warning: $uri from outer scope has stripped <user> part from http://users.livejournal.com/<user> URLs
-            my $uri  = LJ::Request->uri;
-            my $current_url = "http://$host$uri";
-            my $journal_base = $u->journal_base;
-            if (substr($current_url, 0, length($journal_base)) ne $journal_base) {
-                my $new_url = $journal_base;
-                if ($host =~ /^(?:users|community)\./) {
-                    $uri =~ s!^/[^/]+!!;
-                }
-                return redir("$journal_base$uri$args_wq", LJ::Request::HTTP_MOVED_PERMANENTLY());
-            }
-        }
 
         if ($u->is_community) {
             LJ::run_hook('vertical_tags', $remote, $u);

Modified: trunk/cgi-bin/LJ/User.pm
===================================================================
--- trunk/cgi-bin/LJ/User.pm	2012-03-16 11:30:45 UTC (rev 21433)
+++ trunk/cgi-bin/LJ/User.pm	2012-03-16 12:04:11 UTC (rev 21434)
@@ -333,7 +333,7 @@
     }
 
     # subdomains that hold a bunch of users (eg, users.siteroot.com/username/)
-    if ($url =~ m!^http://(\w+)\.\Q$LJ::USER_DOMAIN\E/([\w-]+)/?$!) {
+    if ($url =~ m!^http://(\w+)\.\Q$LJ::USER_DOMAIN\E/([\w_-]+)/?!) {
         if ( $LJ::IS_USER_DOMAIN->{$1} ) {
             return $2;
         }

Tags: livejournal, pm, vad, vadvs
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments