Page MenuHomePhabricator

TOC anchor name collision (collision avoidance salting can still collide with similar headings)
Closed, ResolvedPublic

Description

Author: greg1234321

Description:
---TOC----

  1. test
  2. test
  3. test 2

--/TOC----

== test ==

== test ==

== test 2 ==

talking about the anchors:

The TOC will call the first header 'test'.

To avoid a collision, the TOC will call the second header 'test_2'. Clever TOC.

The TOC will call the third header 'test_2', thus colliding with the other test_2. Silly TOC.

iow, clicking "3. test 2" in the TOC will jump to "2. test".

Dunno, guess it should check for that or something?


Version: 1.16.x
Severity: trivial

Event Timeline

bzimport raised the priority of this task from to Low.Nov 21 2014, 11:09 PM
bzimport added a project: MediaWiki-Parser.
bzimport set Reference to bz24787.
bzimport added a subscriber: Unknown Object (MLST).

greg1234321 wrote:

More normally (in case that was confusing):

  1. copy/paste:

[wiki]
TOC

test

test

test 2

[/wiki]

into a wiki page.

  1. click "3 test 2" in the TOC

expected results: jumps to third header (test 2)
actual results: jumps to second header (test)

due to the anchor-naming system used to avoid collisions.

Seems like it would be an e(In reply to comment #2)

---TOC----

  1. test
  2. test
  3. test 2

--/TOC----

test

test

test 2

.....
talking about the anchors:

The TOC will call the first header 'test'.

To avoid a collision, the TOC will call the second header 'test_2'. Clever
TOC.

The TOC will call the third header 'test_2', thus colliding with the other
test_2. Silly TOC.

iow, clicking "3. test 2" in the TOC will jump to "2. test".

Dunno, guess it should check for that or something?

I see this often actually... Seems like it would be an easy enough fix though.

To avoid a collision, the TOC should just call the second header 'test_%E2%84%962'. (test_№2)
Then 'test_2' wouldn't be an issue.

Change 181999 had a related patch set (by Jackmcbarn) published:
Fix TOC anchor name collisions in edge cases

https://gerrit.wikimedia.org/r/181999

Patch-For-Review

Change 181999 merged by jenkins-bot:
Fix TOC anchor name collisions in edge cases

https://gerrit.wikimedia.org/r/181999

Jackmcbarn claimed this task.