Page MenuHomePhabricator

Reference popup does not show for refs whose names contain a hash sign (#)
Closed, ResolvedPublic0 Estimated Story PointsBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

a<ref name="normal">foo</ref>

b<ref name="#broken">bar</ref>
  • Click or tap on both reference footnotes

What happens?:
The reference popup shows for the first ref, but not for the second. An error message appears in the browser console:

What should have happened instead?:
The reference popup should show for both refs.

Other information (browser name/version, screenshots, etc.):
Reproduced with Firefox 110 and Edge 110.

Seems to be caused by resources/skins.minerva.scripts/references.js line 28 ff. Setting a breakpoint there and manually fixing the value of the href variable causes the popup to appear.

Implementation

  • there is a solution for blank spaces in ref names already, follow that pattern here as well

Event Timeline

Jdlrobson renamed this task from Reference popup does not show for refs whose names contain a hash sign (#) to Reference names can generate ID attributes containing illegal hash sign (#).Mar 14 2023, 4:28 PM
Jdlrobson subscribed.

This is greating an element ID "cite_note-#broken-2" which is an invalid ID attribute according to the HTML spec so I suspect this needs fixing in Cite/Parser which would automatically fix the UI. I suggest not using hash fragments in reference names until that's fixed.

matmarex renamed this task from Reference names can generate ID attributes containing illegal hash sign (#) to Reference popup does not show for refs whose names contain a hash sign (#).Mar 14 2023, 4:52 PM

It's not invalid in HTML5. It only disallows spaces. https://html.spec.whatwg.org/multipage/dom.html#the-id-attribute

That link isn't working for me Bartosz [1]. Regardless of the spec, it does seem like it might be a useful constraint to have since many gadgets/scripts split by hash fragment, so I would appreciate some input form the parser and cite maintainers about whether it's worth mapping this character to something else.

[1] In that it's linking to "DOM defines the user agent requirements for the class, id, and slot attributes for any element in any namespace. [DOM]" in Firefox and "When an element's content model is nothing, the element must contain no Text nodes (other than inter-element whitespace) and no element nodes." in Chrome. I'm not seeing any notes about valid characters for some reason.

It's not invalid in HTML5. It only disallows spaces. https://html.spec.whatwg.org/multipage/dom.html#the-id-attribute

That link isn't working for me Bartosz [1].

[1] In that it's linking to "DOM defines the user agent requirements for the class, id, and slot attributes for any element in any namespace. [DOM]" in Firefox and "When an element's content model is nothing, the element must contain no Text nodes (other than inter-element whitespace) and no element nodes." in Chrome. I'm not seeing any notes about valid characters for some reason.

It reads: "When specified on HTML elements, the id attribute value must be unique amongst all the IDs in the element's tree and must contain at least one character. The value must not contain any ASCII whitespace." It doesn't mention any other requirements.

image.png (2×3 px, 415 KB)

Regardless of the spec, it does seem like it might be a useful constraint to have since many gadgets/scripts split by hash fragment, so I would appreciate some input form the parser and cite maintainers about whether it's worth mapping this character to something else.

Such mapping existed when the code had to be compatible with the HTML4 spec you linked, and was removed in 2017 by the Parsing team: T176170: Migrate citation IDs to HTML5 encoding. As a Cite maintainer, I am opposed to adding it back.

MinervaNeue and any other code handling links can use the URL API to parse them correctly. https://developer.mozilla.org/en-US/docs/Web/API/URL

Change 982405 had a related patch set uploaded (by Thiemo Kreuz (WMDE); author: Thiemo Kreuz (WMDE)):

[mediawiki/skins/MinervaNeue@master] Fix broken reference popup when name contains # character

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

Change 982405 merged by jenkins-bot:

[mediawiki/skins/MinervaNeue@master] Fix broken reference popup when name contains # character

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

Jdlrobson triaged this task as Medium priority.
Jdlrobson lowered the priority of this task from Medium to Low.
Jdlrobson moved this task from Incoming to QA on the Web-Team-Backlog (FY2023-24 Q2 Sprint 5) board.
Jdlrobson set the point value for this task to 0.