Users provide both properly escaped URLs and raw URLs to my website in text format; for example, I consider these two URLs equivalent:
https://www.cool.com/cool%20beans https://www.cool.com/cool beans
Now I want to display them as <a> tags later, when viewing this data. I am stuck between encoding this text and getting these links:
<a href="https://www.cool.com/cool%2520beans"> <a href="https://www.cool.com/cool%20beans">
Or do not encode it and get the following:
<a href="https://www.cool.com/cool%20beans"> <a href="https://www.cool.com/cool beans">
What is the best way out of the user's point of view with modern browsers? I am torn between doing a decoding skip over their input or the second option mentioned above, where we do not encode the href attribute.
source share