A comma followed by an underscore in a URL results in defunct link

AI-generated summary

The issue involves a URL containing commas and underscores being incorrectly parsed by Discourse’s markdown engine, resulting in malformed links with unintended HTML tags like <em>. adrelanos reported the bug, noting that while commas in URLs are technically valid (though often percent-encoded), the parser misinterprets them. kpfleming suggested commas and spaces should be URL-encoded, but calmh clarified that both commas and underscores are allowed in URLs, and the issue lies in the markdown parser overreaching into the href content. tibarra questioned the correct URL format, while sam acknowledged the problem stems from a complex, legacy regex and deferred the fix until the new markdown engine is implemented. In a follow-up, sam confirmed the issue is now resolved — the URL renders correctly and auto-links as intended, thanks to the updated engine referenced in this meta thread.

<a href="https://www.whonix.org/wiki/Comparison_Of_Tor_with_CGI_Proxies,_Proxy_Chains,_and_VPN_Services#Comparison_of_Tor_and_VPN_services">here</a>

results in:

here

https://www.whonix.org/wiki/Comparison_Of_Tor_with_CGI_Proxies,%3Cem%3EProxy%3C/em%3EChains,%3Cem%3Eand%3C/em%3EVPN_Services#Comparison_of_Tor_and_VPN_services

It adds extra <em> after the comma.

Not great to have , inside links indeed, but I perhaps this could be fixed anyhow?

2 curtidas

Spaces are not allowed in URLs, they are supposed to be URL-encoded. Commas should be URL-encoded as well. How did you obtain a URL with embedded commas and spaces?

Both commas and underscores (which I think is the problematic character here) are perfectly fine in URLs. The comma is a reserved character so may be percent escaped to avoid it being interpreted in a reserved manner by the server, but the client shouldn’t care either way.

In this case it looks like the markdown parser is looking too deep into the tag…

1 curtida

And how is the URL supposed to be @adrelanos?

Logic is in a nasty regex that I do not want to hack on, we get a brand new regex with the new markdown engine, this fix will have to wait till then

2 curtidas

This now works, for added bonus it also auto links correctly.

2 curtidas