A bug has been reported where links created using the Composer’s “Insert link” modal break when they contain a ' character encoded as %27. nathank first observed the issue with a Data Explorer URL, but per1234 clarified it’s a broader problem affecting any URL with percent-encoded content when inserted via the link modal. The URL is corrupted during the process, resulting in a broken link. renato confirmed the issue is exclusive to the link modal, as pasting the URL directly works. Moin noted the broken link points to an incorrect target, and sam also recalled the issue. The problem is not limited to Data Explorer and affects the Composer universally.
This is an example link thus created (private sorry): https://ehealthforum.nz/g/HiNZ-staff/reports/128?params=%7B%22topic_id%22%3A%2234521%22%7D
When I add this link to some text here something goes screwy with the URL encoding and we get this: https://ehealthforum.nz/g/HiNZ-staff/reports/128?params=%257B%2522topic_id%2522%253A%252234521%2522%257D
And that beautifully breaks the site!
If I simply paste the link in the post, this doesn’t happen - it is only when I add it to text. So something goes funny when it encounters some existing encoding I think.
@nathank’s report focused on the specific niche thing they happened to be doing when they encountered the bug. However, the bug is in no way specific to Data Explorer. I fear the overly narrow focus of the report, and the use of the irrelevant data-explorer tag (the appropriate tag would be composer), might result in it being difficult for the Discourse team to interpret, or in it not being given the appropriate level of attention.
The fault occurs universally under the following conditions:
The link is added to the post via the “Insert link” dialog.
The URL is always corrupted under these conditions.
Reproducible steps:
Open the following URL in your web browser: https://en.wikipedia.org/wiki/Horncastle_boar%27s_head
(note that the URL contains the ' character’s percent-encoding %27) The expected page opens.
Click the “Link” icon on the post composer.
The “Insert link” dialog will open.
Enter the above URL in the “Link or topic” field of the dialog.
Click the “Insert” button.
The target of the link added through the above procedure is the incorrect: https://en.wikipedia.org/wiki/Horncastle_boar%2527s_head
instead of the correct URL: https://en.wikipedia.org/wiki/Horncastle_boar%27s_head
The link will not lead to the intended page.
This happened because the % character of the percent encoding %27 was encoded redundantly, causing the % to be replaced by its own percent-encoding %25, resulting in the correct URL content %27 being corrupted to %2527