Urlencode fragments when redirecting after editing
authorMax Semenik <maxsem.wiki@gmail.com>
Mon, 18 Mar 2019 05:42:42 +0000 (22:42 -0700)
committerMax Semenik <maxsem.wiki@gmail.com>
Tue, 26 Mar 2019 03:30:00 +0000 (20:30 -0700)
This is a quick fix for the main symptom of the Chrome bug that results in
users being redirected to Special:BadTitle after section editing. We'll
need to discuss a more permanent solution.

Bug: T216029
Change-Id: I4b2d42ebc74031df86bc52310da71819da11c1ae

RELEASE-NOTES-1.31
includes/EditPage.php

index 5eacf55..901c83a 100644 (file)
@@ -62,6 +62,8 @@ THIS IS NOT A RELEASE YET
 * (T199474) Fix typo in rebuildrecentchanges.php resulting in rogue flags.
 * (T218608) Fix an issue that prevents Extension:OAuth working when
   $wgBlockDisablesLogin is true.
+* (T216029) Chrome redirects to Special:BadTitle after editing a section with
+  a non-Latin name on a page with non-Latin characters in title.
 
 == MediaWiki 1.31.1 ==
 
index a1d9ae8..5c37c42 100644 (file)
@@ -4578,7 +4578,10 @@ ERROR;
                        return $wgParser->guessLegacySectionNameFromWikiText( $text );
                }
                // Meanwhile, real browsers get real anchors
-               return $wgParser->guessSectionNameFromWikiText( $text );
+               $name = $wgParser->guessSectionNameFromWikiText( $text );
+               // With one little caveat: per T216029, fragments in HTTP redirects need to be urlencoded,
+               // otherwise Chrome double-escapes the rest of the URL.
+               return '#' . urlencode( mb_substr( $name, 1 ) );
        }
 
        /**