From c520c19a762d5116421b84d071f715ce22c6cc03 Mon Sep 17 00:00:00 2001 From: Max Semenik Date: Sun, 17 Mar 2019 22:42:42 -0700 Subject: [PATCH] Urlencode fragments when redirecting after editing 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 | 2 ++ includes/EditPage.php | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/RELEASE-NOTES-1.31 b/RELEASE-NOTES-1.31 index 5eacf552a8..901c83a5fc 100644 --- a/RELEASE-NOTES-1.31 +++ b/RELEASE-NOTES-1.31 @@ -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 == diff --git a/includes/EditPage.php b/includes/EditPage.php index a1d9ae82d5..5c37c42591 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -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 ) ); } /** -- 2.20.1