Page MenuHomePhabricator

Title::getFragmentForURL escapes $
Open, Needs TriagePublic

Description

I have a Title that links to a Wikibase statement: Item:Q1#Q1$4646fb00-4c25-f2de-76e0-b512e49c762b

While this Title displays correctly, the URL obtained in LinkRenderer by calling getLinkURL on Title returns Item:Q1#Q1.244646fb00-4c25-f2de-76e0-b512e49c762b. Instead of $ it has .24. This breaks navigation to, and highlighting off, the right section of the page.

Things either go wrong in Title::getFragmentForURL or further down (in Sanitizer::escapeIdForLink). $this->mFragment is fine in getFragmentForURL but once it gets given to Sanitizer::escapeIdForLink the return value is wrong (no longer has the $). So either calling Sanitizer::escapeIdForLink is not the right thing to do, or Sanitizer::escapeIdForLink itself is doing something wrong.

Seen on 1.35.0-alpha (ad4a3ba) with 7.4.6

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptJun 29 2020, 3:39 PM

The $ symbol is lost when the fragment is passed through PHP's urlencode() inside Sanitizer::escapeIdInternal().