Page MenuHomePhabricator

Extra spaces are meaningful in sfn (differs from article text behavior)
Closed, ResolvedPublic

Description

You can read the discussion at Template talk:Sfn, but extra spaces in sfn break the functionality in a silent, nonobvious way. This differs from the behavior of article text, where extra spaces are stripped, and no warning is displayed, so users will be completely unaware of the lack of functionality.

Details

Related Gerrit Patches:

Event Timeline

Lingzhi created this task.Jan 15 2018, 1:55 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptJan 15 2018, 1:55 PM
Aklapper updated the task description. (Show Details)Jan 15 2018, 1:56 PM

@Lingzhi: Thanks for reporting this and welcome to Phabricator!

This task seems to refer to https://en.wikipedia.org/wiki/Template_talk:Sfn#Bug_in_either_sfn_or_sfnRef and the sentence

This is not necessarily the fault of {{sfn}}, but rather is the fault of MediaWiki which appears to be handling the cite-note links and ids differently.

(This task welcomes editing its task description to make it clearer by providing sections for: Description of the problem; expected behavior; actual behavior. See https://mediawiki.org/wiki/How_to_report_a_bug for future reference.)

Are you waiting for me? I thought "Description of the problem; expected behavior; actual behavior" were all quite obvious, especially since another editor spelled out the issue in deeper detail.

Extra blank spaces that are always stripped out in wikitext (even between "nowiki" tags!) are not being stripped out in sfn. This is confusing to users:

{{sfn|Smith|1987|p = 7 note 4}} is different from {{sfn|Smith|1987|p = 7 note 4}}; the latter will not link to the relevant cite. Expected behaviosr is that extra spaces should be meaningless, and it should link to the relevant cite.

I know loc= should have been used in this case; I encountered it while copy editing.... I have no idea whether blank spaces in other locations also break the link.

PS the example above (as displayed, not as originally typed) doesn't make sense because even your comment boxes here strip out the extra blank spaces that I put in the original text.

especially since another editor spelled out the issue in deeper detail.

Preferably that should be in this very task and not hidden in some link with a lenghty discussion. :)
But I guess it is clearer now.

PS the example above (as displayed, not as originally typed) doesn't make sense because even your comment boxes here strip out the extra blank spaces that I put in the original text.

You can use Markdown markup to not strip extra blank spaces. See https://www.mediawiki.org/wiki/Phabricator/Help#Formatting

Izno moved this task from Unsorted backlog to Defect backlog on the Cite board.Jan 19 2018, 2:27 PM
This comment was removed by David_J_Wilson.
David_J_Wilson added a comment.EditedJan 23 2018, 12:31 AM
…………

(This task welcomes editing its task description to make it clearer by providing sections for: Description of the problem; expected behavior; actual behavior. See https://mediawiki.org/wiki/How_to_report_a_bug for future reference.)

Description: A reference name containing a double underscore produces an inline link which does not work. The back-link from the footnote to the text does not work either.

Example: (from https://en.wikipedia.org/wiki/Help_talk:Footnotes#Double_underscores_in_footnote_names )

Footnote constructor: <ref name="garlic__bread">Here is an example</ref>

Anchor produced at footnote: <li id="cite_note-garlic__bread-1">, as expected
Anchor produced at reference superscript is also as expected. Apart from having two underscores between "garlic" and "bread" rather than one, the anchor id is the same as its corresponding link below. I can't display it here because a second pair of successive underscores will screw up the display.

Link to footnote produced: <a href="cite_note-garlic_bread-1"> with only one underscore between "garlic" and "bread" instead of the expected two.
Back link produced: <a href="cite_ref-garlic_bread_1-0"> ditto

Cause: The link and anchor names don't match because the former erroneously have only one underscore between "garlic" and "bread" instead of the expected two.

…………

(This task welcomes editing its task description to make it clearer by providing sections for: Description of the problem; expected behavior; actual behavior. See https://mediawiki.org/wiki/How_to_report_a_bug for future reference.)

Description: A reference name containing a double underscore produces an inline link which does not work. The back-link from the footnote to the text does not work either.
Example: (from https://en.wikipedia.org/wiki/Help_talk:Footnotes#Double_underscores_in_footnote_names )
Footnote constructor: <ref name="garlicbread">Here is an example</ref>
Anchor produced at footnote: <li id="cite_note-garlic
bread-1">, as expected
Anchor produced at reference superscript is also as expected. I can't quote it because another double underscore will screw up the text displayed. However, apart from a double underscore between "garlic" and "bread" instead of one, its name is the same as that of the back link given below.
Link to footnote produced: <a href="cite_note-garlic_bread-1"> with only one underscore between "garlic" and "bread" instead of the expected two.
Back link produced: <a href="cite_ref-garlic_bread_1-0"> ditto
Cause: The link and anchor names don't match because the former erroneously have only one underscore between "garlic" and "bread" instead of the expected two.

Update: When a sequence of several successive underscores occur in a reference name, this is collapsed into a single underscore in the link name produced, but is kept in its entirety in the corresponding anchor name

Change 474746 had a related patch set uploaded (by Thiemo Kreuz (WMDE); owner: Thiemo Kreuz (WMDE)):
[mediawiki/extensions/Cite@master] Sanitize underscores as core does, to not create broken links

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

thiemowmde triaged this task as Medium priority.Nov 19 2018, 5:13 PM
thiemowmde added a project: patch-welcome.
thiemowmde added a subscriber: thiemowmde.

I had a brief look at this and found this is, technically, not a Cite but a MediaWiki core issue.

Cite uses a few messages that contain something like [[#$1|$2]] to render links. Spaces and underscores are passed to these wikitext links as expected, e.g. [[#garlic__bread|example]]. It's MediaWiki core's link renderer that changes these anchor tags by merging consecutive underscores.

The line of code responsible for this unexpected behavior is https://phabricator.wikimedia.org/source/mediawiki/browse/master/includes/title/MediaWikiTitleCodec.php$274.

Possible solutions:

  • Change MediaWikiTitleCodec to do this whitespace cleanup only before #, but not after. Note this will most probably be a breaking change people are not willing to accept.
  • Add a similar cleanup rule to Cite::normalizeKey. Note this might lead to another unexpected situation, where two references with seemingly different keys (e.g. a_b and a__b) will conflict. However, the patch I just uploaded is probably not making this worse, as this situation already creates conflicts.

Change 474746 merged by jenkins-bot:
[mediawiki/extensions/Cite@master] Sanitize underscores as core does, to not create broken links

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

thiemowmde closed this task as Resolved.Dec 11 2018, 8:37 AM
thiemowmde claimed this task.
thiemowmde removed a project: Patch-For-Review.