Skip to main content.
home | support | download

Back to List Archive

Re: Ampersands are being converted

From: Bill Moseley <moseley(at)not-real.hank.org>
Date: Tue Sep 21 2004 - 13:49:37 GMT
On Tue, Sep 21, 2004 at 08:58:18AM -0400, Terry Gliedt wrote:
> I was surprised at &amp;.  I had expected to see & instead of &amp;. 
> The char entity isn't needed of course, since the href value is not 
> rendered visible in the page.

No, that's not really correct.  Your browser is just being nice and
allowing the naked ampersand.  It's suppose to be there -- you have
been writing invalid (unvalidated) hrefs for years. ;)

  http://www.w3.org/TR/html401/appendix/notes.html#h-B.2.2
  http://www.htmlhelp.com/tools/validator/problems.html#amp


Consider this url which selects which amplifier to use to play your
music on your home media network and how many times to repeat it:

  http://localhost/play_song.cgi?volume=39&amp=2&copy=2&name=whitewedding

You can see that &amp and &copy are a bit confusing.  Those equal
signs after &amp and &copy, in general, terminate the entity without
the need for the explicit semicolon.

Don't believe me?  Drop this into your web server and click on the
link:

#!/usr/bin/perl -w
use strict;

my $query = $ENV{QUERY_STRING} || "blank";

print <<EOF
Content-type: text/html

<html><head><title>Test &amp; in hrefs</title></head>
<body>
Current passed query string = [$query]
<p>
<a href="$ENV{SCRIPT_NAME}?volume=39&amp=2&copy=2&name=whitewedding">play</a>
</body>
</html>
EOF

Try running that through an HTML validator.


> See the 'Next 15' link. It contains 'use=fusion', but the other links to 
> pages do not. So when I click on '2', the link fails because swish.cgi 
> is looking for the default datebase (default.index). But the script did 
> know enough to specify the use= keyword for 'Next 15'.

Where does that "use" parameter come from?  It's not how swish.cgi
selects different index files (with the "select_indexes" feature) if
that's what you mean by "database" above.


-- 
Bill Moseley
moseley@hank.org

Unsubscribe from or help with the swish-e list: 
   http://swish-e.org/Discussion/

Help with Swish-e:
   http://swish-e.org/current/docs
   swish-e@sunsite.berkeley.edu
Received on Tue Sep 21 06:50:15 2004