question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Ampersand is wrongly escaped in href attribute.

See original GitHub issue

This is related to #189 But still not solved.

Thymeleaf seems to be escaping the & character while rendering the th::href attribute

as a comment to this issue @jmiguelsamper said

Escaping ampersand inside an attribute is correct HTML.

If this is the case, how could I pass the following url?

http://example.com?id=20&somevar=content_with_&rr=29

Here, I have only two parameters: id => 20 and somevar => content_with_&rr=29

but according to the reply, it will have three parameters (id => 20, somevar => content_with_, rr =>29)

Also when I tried https://www.google.co.in/search?source=hp&q=thymeleaf instead of https://www.google.co.in/search?source=hp&q=thymeleaf I got the wrong page. So clearly, & is not same as & in urls.

So can you tell me how can I add & in urls with Thymeleaf?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
harikkcommented, Feb 6, 2016

But how do I solve the problem with emails?

0reactions
bhaskeycommented, Feb 15, 2021

@harikk did you solve this? I am having similar issue!

I understand that escaping & into & is correct way and it doesn’t really change the actual url, but we use a system which reads the URLs and it doesn’t work with escaped characters and I do not have any control over it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Do I encode ampersands in <a href...>? - Stack Overflow
It will remain possible to escape ampersands in attribute values, but apart from validation with current tools, there is no practical need to...
Read more >
Ampersands in URL's escaped into HTML entitites, breaking ...
The ampersand near the end of the URL is converted to an entity (&) by TinyMCE, even when it is an attribute in...
Read more >
Why is it important to escape & in href attributes in tags?
It really depends on what you have in that attribute. If you have href="?something&=whatever" you run into a problem if you don't escape...
Read more >
Change html5 formatter to escape only ambiguous ampersands
I think in general, automatically trying to escape any tag attributes is a deeply problematic behaviour.
Read more >
Decode (or encode) "&_amp_;" in html string? - OutSystems
I try to decide to replace the Ampersand characters inside the string ... difficult since the URL text is inside an attribute/parameter.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found