weavejester / hiccup

Fast library for rendering HTML in Clojure
http://weavejester.github.io/hiccup
Eclipse Public License 1.0
2.68k stars 174 forks source link

link-to encodes & in href #111

Closed mvitz closed 7 years ago

mvitz commented 9 years ago

It seems hiccup escapes the URI given to link-to. If this is intended behaviour you can close this issue but at least for me this behaviour was unexpected.

Expected:

(use 'hiccup.element)
(use 'hiccup.core)
(html (link-to "/foobar?foo=bar&foo=baz")) #-> "<a href=\"/foobar?foo=bar&foo=baz\"></a>"

Actual:

(use 'hiccup.element)
(use 'hiccup.core)
(html (link-to "/foobar?foo=bar&foo=baz")) #-> "<a href=\"/foobar?foo=bar&amp;foo=baz\"></a>"
weavejester commented 9 years ago

Yes, that's the correct behavior.

It's worth noting that HTML5 now allows for bare ampersands in certain attributes, and browsers have coped with this for a while. However, using bare ampersands leads to ambiguities in certain cases. For instance, what if you had a URI like /foo=&amp;?