From f3f82e3f60c8b72af70b5be287dee758d04962dd Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Thu, 13 Mar 2008 18:30:50 +0000 Subject: [PATCH] * (bug 10721) Duplicate section anchors with differing case now disambiguated for Internet Explorer's sake --- RELEASE-NOTES | 3 +++ includes/Parser.php | 9 +++++++-- maintenance/parserTests.txt | 11 +++++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 8100b84fc1..c2888ad7a3 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -81,6 +81,9 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN case-insensitive names. * Adding the fix for lists in RTL wikis to more skins, and fixing the image toc * (bug 8157) Remove redirects from Special:Unusedtemplates. Patch by WebBoy. +* (bug 10721) Duplicate section anchors with differing case now disambiguated + for Internet Explorer's sake + === API changes in 1.13 === diff --git a/includes/Parser.php b/includes/Parser.php index acefb8dcaa..ef4e2a1ed9 100644 --- a/includes/Parser.php +++ b/includes/Parser.php @@ -3494,11 +3494,16 @@ class Parser # Save headline for section edit hint before it's escaped $headlineHint = $safeHeadline; $safeHeadline = Sanitizer::escapeId( $safeHeadline ); + # lowercase headline, since some browser don't distinguish + # "Anchor" from "anchor" (bug #10721) + $arrayKey = strtolower( $safeHeadline ); + + # XXX : Is $refers[$headlineCount] ever accessed, actually ? $refers[$headlineCount] = $safeHeadline; # count how many in assoc. array so we can track dupes in anchors - isset( $refers[$safeHeadline] ) ? $refers[$safeHeadline]++ : $refers[$safeHeadline] = 1; - $refcount[$headlineCount] = $refers[$safeHeadline]; + isset( $refers[$arrayKey] ) ? $refers[$arrayKey]++ : $refers[$arrayKey] = 1; + $refcount[$headlineCount] = $refers[$arrayKey]; # Don't number the heading if it is the only one (looks silly) if( $doNumberHeadings && count( $matches[3] ) > 1) { diff --git a/maintenance/parserTests.txt b/maintenance/parserTests.txt index fb9708a2c7..2e72415c81 100644 --- a/maintenance/parserTests.txt +++ b/maintenance/parserTests.txt @@ -3551,6 +3551,17 @@ Resolving duplicate section names !! end +!! test +Resolving duplicate section names with differing case (bug 10721) +!! input +== Foo bar == +== Foo Bar == +!! result +

[edit] Foo bar

+

[edit] Foo Bar

+ +!! end + !! article Template:sections !! text -- 2.20.1