Last modified: 2010-12-17 16:37:27 UTC

Wikimedia Bugzilla is closed!

Wikimedia has migrated from Bugzilla to Phabricator. Bug reports should be created and updated in Wikimedia Phabricator instead. Please create an account in Phabricator and add your Bugzilla email address to it.
Wikimedia Bugzilla is read-only. If you try to edit or create any bug report in Bugzilla you will be shown an intentional error message.
In order to access the Phabricator task corresponding to a Bugzilla report, just remove "static-" from its URL.
You could still run searches in Bugzilla or access your list of votes but bug reports will obviously not be up-to-date in Bugzilla.
Bug 10721 - Case insensitivity in section anchors
Case insensitivity in section anchors
Product: MediaWiki
Classification: Unclassified
Parser (Other open bugs)
All All
: Low trivial (vote)
: ---
Assigned To: Nobody - You can work on this!
: patch, patch-need-review
Depends on:
Blocks: 3950
  Show dependency treegraph
Reported: 2007-07-27 13:57 UTC by Chris
Modified: 2010-12-17 16:37 UTC (History)
3 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---

proposed patch (1.05 KB, patch)
2008-03-13 09:37 UTC, Nicolas Dumazet

Description Chris 2007-07-27 13:57:40 UTC
Currently, sections on a MediaWiki page are associated with anchors with a name and id based on the title of the section. If there are multiple sections with the same name, then each one after the first has a number appended, so that they're unique.

However, at least on IE7 (running on Windows XP), the browser does not distinguish between two anchor names that differ only by case, whereas MW currently does distinguish, so a link with an anchor intending to link to the second section instead goes to the first one.

Example: Today, on en:w:Help Desk, there was a section titled "Adding external links", and one further down titled "Adding External Links" (or something fairly similar). MW treated the two titles as different, and so didn't add a number to the second in the anchor name, but IE7, when told to go to "#Adding External Links", went to the first one.
Comment 1 stux 2007-09-29 18:14:39 UTC
Added to tracker
Comment 2 Nicolas Dumazet 2008-03-13 07:59:09 UTC
How is that simple patch ? 

Index: Parser.php
--- Parser.php	(révision 31892)
+++ Parser.php	(copie de travail)
@@ -3494,6 +3494,10 @@
 			# Save headline for section edit hint before it's escaped
 			$headlineHint = $safeHeadline;
 			$safeHeadline = Sanitizer::escapeId( $safeHeadline );
+			# lowercase headlines, since some browser don't distinguish
+			# "Anchor" from "anchor" (bug #10721)
+			$safeHeadline = strtolower($safeHeadline)
 			$refers[$headlineCount] = $safeHeadline;
 			# count how many in assoc. array so we can track dupes in anchors

Comment 3 Nicolas Dumazet 2008-03-13 09:37:57 UTC
Created attachment 4709 [details]
proposed patch

I obviously didn't think enough when posting my previous comment. (!) Lowercase safeHeadline would eventually imply a lowercase anchor, meaning that a link to section "John Doe" would be #john_doe. Quite annoying, in fact.

Attached a better patch, where only the key to the associative array is lowercase.

Found a strange array entry which is apparently never accessed. Could someone check  this ?
Comment 4 Brion Vibber 2008-03-13 18:33:32 UTC
Note, this lovely feature appears to be unique to Internet Explorer. :) Firefox, Opera, and Safari all consider the differently-cased anchors to be separate and distinct.

It is however alleged that XHTML rules require the disambiguation anyway.

Added patch (with code fix) and parser test case in r31931... thanks for the patch!
Comment 5 Happy-melon 2010-12-17 16:37:27 UTC
Cf comments in r74533.

Note You need to log in before you can comment on or make changes to this bug.