FAQ: Tidy breaks my URIs by converting ampersands to &

Unescaped ampersands are illegal most of the time in HTML and XHTML and
user agents treat them differently. Tidy tries a best guess on what you
really wanted to write and escapes the ampersands accordingly. For
example,

  ... href="http://www.example.org/script?x=1&y=2"

will become

  ... href="http://www.example.org/script?x=1&y=2"

Tidy does not change your URI, it changes the (X)HTML representation of
it. While your script might stop working if you pass the URI including
the & directly, the link will still work, since user agents will
unescape the & and request the right thing. Tidy doesn't break
anything here, it corrects your possible error and increases stability
of your document. This is not a bug. However, *if you /really/ want to
change this behaivour* you may use the `--QuoteAmpersand no`
configuration option to prevent proper escaping of ampersands, but don't
do this for reasons of validity and [potential problems this might
cause] (http://ppewww.ph.gla.ac.uk/~flavell/www/formgetbyurl.html).
Please also take a look at [Appendix B.2.2 of the HTML 4.01
recommendation] (http://www.w3.org/TR/html4/appendix/notes.html#h-B.2.2)
discussing the same issue.

Received on Sunday, 31 March 2002 11:56:19 UTC