Page MenuHomePhabricator

Decode URLs in statements when displaying them
Open, Needs TriagePublicFeature

Description

Wikibase should decode percent-encoded URLs in statements when displaying them, similar to what was done for the query service in T327514.

Browsers typically display an unencoded URL in the address bar but use the percent-encoded form when the copying URLs. Storing URLs unencoded can also be problematic, e.g. applying Unicode normalisation can break the URL, like reported in T206188.

But when a URL contains a lot of non-ASCII characters, it creates very long, unreadable URLs, which people understandably don't like and sometimes try to avoid.

Decoding them when displaying them would make them more readable while still being able to store them in the encoded form.

The example from T206188 (https://www.wikidata.org/w/index.php?oldid=756586516):

How it currently appears:

Bildschirmfoto_2024-02-21_16-05-30.png (281×926 px, 36 KB)

How it appears after decoding the URL:

Bildschirmfoto_2024-02-21_16-05-55.png (157×922 px, 14 KB)

I used the following bit of code in the browser console to change the link text (I didn't check whether the decoded URL is valid UTF-8):

for (let e of document.querySelectorAll("a.external")) {
	if (e.textContent === e.href) {
		e.textContent = decodeURI(e.textContent);
	}
}

Event Timeline

An issue to consider is user may often copy the displayed URL to address bar, Wikipedia, and other URL field. If the URL contain double encoded character (%2520) it will be changed to single encoded (%20) and will break the URL if copied as displayed.