Uli Wortmann asked about protecting the & in a URL, 
obtained via \htmladdnormallink:

> Ross MOORE wrote:
> > 
> > > Hello Hans,
> > >
> > >     >> \htmlhead{section} {\htmladdnormallink{Guest Book}
> > >     >> {http://www2.spoc.ethz.ch/cgi-bin/spoc
> > >     >> /ms-guest.pl?file=guest&template=guest/spoc-node13.html"}}
> > >     >>
> > >     >> However, the special characters get translated into 'garbage'
> > >     >> How do I protect them from getting transformed?

Hans Steffani suggested escaping them, e.g.;    guest\&template

which converts the &  to the entity  &

 ... and the question was raised as to whether this is the correct
thing to do.

> [...]
> > But this is HTML, not XML, and what is one supposed with existing software
> > that does it wrong ?
> > Would someone please check out what the HTML recommendations are,
> > for this situation.
> How about "Ampersands in URI attribute values" at
> http://www.w3.org/TR/REC-html40/appendix/notes.html#h-B.2.2
> 
> Hans Braun

Thanks Hans.
Indeed it *is* the correct action, as the first paragraph from
this page recommends:


B.2.2 Ampersands in URI attribute values

The URI that is constructed when a form is submitted may be used as an anchor-style 
link (e.g., the href attribute for the A
element). Unfortunately, the use of the "&" character to separate form fields 
interacts with its use in SGML attribute values to
delimit character entity references. For example, to use the URI 
"http://host/?x=1&y=2" as a linking URI, it must be written <A
href="http://host/?x=1&#38;y=2"> or <A href="http://host/?x=1&amp;y=2">. 


So it is up to the program, or cgi-script, receiving the URI
to interpret the entity correctly.

If it is old software that does *not* interpret the entity,
then you'll have to write your own extra post-processing script
to change  &amp;  back to  '&' .
However, this may mean that some browsers will not *send* the 
correct URI to the cgi-script, and may even fail to render the
HTML pages correctly.

In short, best advice is to update the cgi-script.
LaTeX2HTML is already doing the best it can.


Hope this helps,

        Ross Moore

Reply via email to