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>
Mon, 18 Mar 2019 05:42:42 +0000 (22:42 -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.33
includes/EditPage.php

index 405d5a7..bc449c7 100644 (file)
@@ -128,6 +128,8 @@ For notes on 1.32.x and older releases, see HISTORY.
 === Bug fixes in 1.33 ===
 * (T164211) Special:UserRights could sometimes fail with a
   "conflict detected" error when there weren't any conflicts.
+* (T216029) Chrome redirects to Special:BadTitle after editing a section with
+  a non-Latin name on a page with non-Latin characters in title.
 
 === Action API changes in 1.33 ===
 * (T198913) Added 'ApiOptions' hook.
index 41238df..23cdc3b 100644 (file)
@@ -4557,7 +4557,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 ) );
        }
 
        /**