467,903 Members | 1,700 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,903 developers. It's quick & easy.

ampersand in urls when using xhtml 1.0 strict

When I write a url in xhtml, with an unencoded ampersand, like this:

http://localhost:2063/Client/ViewRep...8&Type=SUMMARY

the xhtml sytax checker correctly indicates an error, telling me that
it should be:

http://localhost:2063/Client/ViewRep...p;Type=SUMMARY

see: <http://www.htmlhelp.com/tools/validator/problems.html#amp>

However the last sentence there ends:

"the browser translates "&amp;" to "&" so the Web server would only
see "&" and not "&amp;" in the query string of the request."

My web server is clearly seeing &amp; and the browser (FF 1.0.0.11) is
also showing &amp; in the url.

I am using:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

with no xml prefix because, as we all know, IE6 breaks when the xml
prefix is present.

What is the cause and solution of this problem.

I am using FF 1.0.0.11, via a local asp.net 2.0 site through the mini
webserver (Cassini) on WinXP SP2 with all latest o/s updates installed
(apart from IE7, I am using IE6 on this PC).

Do I have to apply a url decode algorithm when the web page loads?
That is far from ideal because the problem here is that the browser is
not showing the decoded url.

Is this a bug in FF?

Finally is there a DOCTYPE I can use to force all the 5 major browsers:
IE6, IE7, FF, Opera, Safari to all render in strict mode when
displaying xhtml?
Dec 17 '07 #1
  • viewed: 4974
Share:
13 Replies
mark4asp wrote:
When I write a url in xhtml, with an unencoded ampersand, like this:

http://localhost:2063/Client/ViewRep...8&Type=SUMMARY

the xhtml sytax checker correctly indicates an error, telling me that
it should be:

http://localhost:2063/Client/ViewRep...p;Type=SUMMARY

see: <http://www.htmlhelp.com/tools/validator/problems.html#amp>

However the last sentence there ends:

"the browser translates "&amp;" to "&" so the Web server would only
see "&" and not "&amp;" in the query string of the request."

My web server is clearly seeing &amp; and the browser (FF 1.0.0.11) is
also showing &amp; in the url.

I am using:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

with no xml prefix because, as we all know, IE6 breaks when the xml
prefix is present.

What is the cause and solution of this problem.

I am using FF 1.0.0.11, via a local asp.net 2.0 site through the mini
webserver (Cassini) on WinXP SP2 with all latest o/s updates installed
(apart from IE7, I am using IE6 on this PC).
You're using 1.0.0.11? The bug is that it's practically the very first
version released and it was superseded by 1.0.1 within a couple of
months, by 1.5 over two years ago, and by 2.0 over a year ago. Based on
usage of the high-traffic site I'm involved with, virtually no one is
using Firefox 1.x any more (probably because Firefox prompts you to
update it), and you *certainly* shouldn't be doing anything with a
version that has been outdated over ten times as long as the product had
existed when the version was replaced.
>
Do I have to apply a url decode algorithm when the web page loads?
That is far from ideal because the problem here is that the browser is
not showing the decoded url.

Is this a bug in FF?
There is no problem with this whatsoever in Firefox 2, I can tell you
that. Use &amp; in your links and images and so forth and it'll work.
Dec 17 '07 #2
mark4asp wrote:
When I write a url in xhtml, with an unencoded ampersand, like this:

http://localhost:2063/Client/ViewRep...8&Type=SUMMARY

the xhtml sytax checker correctly indicates an error, telling me that
it should be:

http://localhost:2063/Client/ViewRep...p;Type=SUMMARY

see: <http://www.htmlhelp.com/tools/validator/problems.html#amp>

However the last sentence there ends:

"the browser translates "&amp;" to "&" so the Web server would only
see "&" and not "&amp;" in the query string of the request."

My web server is clearly seeing &amp; and the browser (FF 1.0.0.11) is
also showing &amp; in the url.

I am using:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

with no xml prefix because, as we all know, IE6 breaks when the xml
prefix is present.

What is the cause and solution of this problem.

I am using FF 1.0.0.11, via a local asp.net 2.0 site through the mini
webserver (Cassini) on WinXP SP2 with all latest o/s updates installed
(apart from IE7, I am using IE6 on this PC).

Do I have to apply a url decode algorithm when the web page loads?
That is far from ideal because the problem here is that the browser is
not showing the decoded url.

Is this a bug in FF?

Finally is there a DOCTYPE I can use to force all the 5 major
browsers: IE6, IE7, FF, Opera, Safari to all render in strict mode
when displaying xhtml?
The immediate problem is now fixed. Somehow the page with the urls was
missing a Content-Type header:
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

After including this header I was able to remove the encoded
ampersands, [ &amp; ], to replace them with just a &. The xhtml
syntax checker no longer indicated errors here and the page navigation
now works.
--

Dec 17 '07 #3
..oO(mark4asp)
>The immediate problem is now fixed. Somehow the page with the urls was
missing a Content-Type header:
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
Surely not. If this "fixed" your problem, then there's something wrong
with your server.
>After including this header I was able to remove the encoded
ampersands, [ &amp; ], to replace them with just a &. The xhtml
syntax checker no longer indicated errors here and the page navigation
now works.
I doubt that. Ampersands in a URL _must_ be encoded.

Micha
Dec 17 '07 #4
mark4asp wrote:
mark4asp wrote:
>When I write a url in xhtml, with an unencoded ampersand, like this:

http://localhost:2063/Client/ViewRep...8&Type=SUMMARY

the xhtml sytax checker correctly indicates an error, telling me that
it should be:

http://localhost:2063/Client/ViewRep...p;Type=SUMMARY

see: <http://www.htmlhelp.com/tools/validator/problems.html#amp>

However the last sentence there ends:

"the browser translates "&amp;" to "&" so the Web server would only
see "&" and not "&amp;" in the query string of the request."

My web server is clearly seeing &amp; and the browser (FF 1.0.0.11) is
also showing &amp; in the url.

I am using:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

with no xml prefix because, as we all know, IE6 breaks when the xml
prefix is present.

What is the cause and solution of this problem.

I am using FF 1.0.0.11, via a local asp.net 2.0 site through the mini
webserver (Cassini) on WinXP SP2 with all latest o/s updates installed
(apart from IE7, I am using IE6 on this PC).

Do I have to apply a url decode algorithm when the web page loads?
That is far from ideal because the problem here is that the browser is
not showing the decoded url.

Is this a bug in FF?

Finally is there a DOCTYPE I can use to force all the 5 major
browsers: IE6, IE7, FF, Opera, Safari to all render in strict mode
when displaying xhtml?

The immediate problem is now fixed. Somehow the page with the urls was
missing a Content-Type header:
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

After including this header I was able to remove the encoded
ampersands, [ &amp; ], to replace them with just a &. The xhtml
syntax checker no longer indicated errors here and the page navigation
now works.
First, this is very strange because if your browser was displaying the
page as HTML, then it was already receiving a content type header from
the web server (which the web server should always send--the META tag
should only be useful for cases where the server isn't sending a content
type header or when you are opening up a static web page directly on
your system instead of requesting it from a web browser) telling it that
the page was HTML, or else there was no header and the browser was
treating it as HTML by default.

Second, this is very strange because NOT encoding ampersands *is*
invalid and the W3C validator wouldn't start treating it as valid
because you included a META tag that wasn't necessary anyway and that
wouldn't cause the effect that you've stated.
Dec 17 '07 #5
On Mon, 17 Dec 2007, Harlan Messinger wrote:
Second, this is very strange because NOT encoding ampersands *is* invalid
No, it isn't. & and &amp; just mean different things.
See the valid page
http://www.unics.uni-hannover.de/nht...ampersand.html

--
In memoriam Alan J. Flavell
http://groups.google.com/groups/sear...Alan.J.Flavell
Dec 17 '07 #6
On Mon, 17 Dec 2007, mark4asp wrote:
Somehow the page with the urls was
missing a Content-Type header:
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
No <metais ever missing. No <metais ever required.
Especially <meta http-equivis a poor ersatz for real HTTP header.
http://www.unics.uni-hannover.de/nht...a-http-equiv.1
http://www.unics.uni-hannover.de/nht...a-http-equiv.2

Learn how to configure your web server correctly:
http://www.w3.org/International/O-HTTP-charset

--
Bugs in Internet Explorer 7
http://www.unics.uni-hannover.de/nhtcapri/ie7-bugs
Dec 17 '07 #7
On Mon, 17 Dec 2007, mark4asp wrote:
When I write a url in xhtml, with an unencoded ampersand,
& and &amp; mean different things:
http://www.unics.uni-hannover.de/nht...ampersand.html
http://www.unics.uni-hannover.de/nht...ampersand.text
I am using:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
What for? You can do everything with HTML 4 Strict.

--
Top-posting.
What's the most irritating thing on Usenet?
Dec 17 '07 #8
Harlan Messinger wrote:
mark4asp wrote:
When I write a url in xhtml, with an unencoded ampersand, like this:

http://localhost:2063/Client/ViewRep...8&Type=SUMMARY

the xhtml sytax checker correctly indicates an error, telling me
that it should be:

http://localhost:2063/Client/ViewRep...p;Type=SUMMARY

see: <http://www.htmlhelp.com/tools/validator/problems.html#amp>

However the last sentence there ends:

"the browser translates "&amp;" to "&" so the Web server would only
see "&" and not "&amp;" in the query string of the request."

My web server is clearly seeing &amp; and the browser (FF 1.0.0.11)
is also showing &amp; in the url.

I am using:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

with no xml prefix because, as we all know, IE6 breaks when the xml
prefix is present.

What is the cause and solution of this problem.

I am using FF 1.0.0.11, via a local asp.net 2.0 site through the
mini webserver (Cassini) on WinXP SP2 with all latest o/s updates
installed (apart from IE7, I am using IE6 on this PC).

You're using 1.0.0.11? The bug is that it's practically the very
first version released and it was superseded by 1.0.1 within a couple
of months, by 1.5 over two years ago, and by 2.0 over a year ago.
Based on usage of the high-traffic site I'm involved with, virtually
no one is using Firefox 1.x any more (probably because Firefox
prompts you to update it), and you certainly shouldn't be doing
anything with a version that has been outdated over ten times as long
as the product had existed when the version was replaced.
Apologies, a typo. I am using FF 2.0.0.11
Do I have to apply a url decode algorithm when the web page loads?
That is far from ideal because the problem here is that the browser
is not showing the decoded url.

Is this a bug in FF?

There is no problem with this whatsoever in Firefox 2, I can tell you
that. Use &amp; in your links and images and so forth and it'll work.
So exactly what should happen.

If I have, say:
<a href="../page1.aspx?a=1&amp;b=gonow">Go Now</a>
in my html, on clicking the link, will FF give :
blah blah/page1.aspx?a=1&b=gonow
in the address bar?

It's not doing that for me. It gives
blah blah/page1.aspx?a=1&amp;b=gonow

Which the server reads and tells me that it can't get my querystrings.
I suppose I can url decode this at the server end to fix it.
Dec 17 '07 #9
"mark4asp" <ma******@gmail.comwrites:
Which the server reads and tells me that it can't get my querystrings.
I suppose I can url decode this at the server end to fix it.
The easy way out is to allow ';' as well as '&' as a separator. Most
web languages/CGI libraries support this either by default or as an
option.

--
Chris
Dec 17 '07 #10
mark4asp wrote:
If I have, say:
<a href="../page1.aspx?a=1&amp;b=gonow">Go Now</a>
in my html, on clicking the link, will FF give :
blah blah/page1.aspx?a=1&b=gonow
in the address bar?

It's not doing that for me. It gives
blah blah/page1.aspx?a=1&amp;b=gonow
Can you post a URL where that happens?

--

Martin Honnen
http://JavaScript.FAQTs.com/
Dec 17 '07 #11
On Mon, 17 Dec 2007, mark4asp wrote:
If I have, say:
<a href="../page1.aspx?a=1&amp;b=gonow">Go Now</a>
Give us the address (URL)!

Meanwhile take this
http://www.unics.uni-hannover.de/nht...ampersand.html
Dec 17 '07 #12
Martin Honnen wrote:
mark4asp wrote:
If I have, say:
<a href="../page1.aspx?a=1&amp;b=gonow">Go Now</a>
in my html, on clicking the link, will FF give :
blah blah/page1.aspx?a=1&b=gonow
in the address bar?

It's not doing that for me. It gives
blah blah/page1.aspx?a=1&amp;b=gonow

Can you post a URL where that happens?
I'm sorry. It is happening right now on my local web-server. This is an
asp.net 2.0 application I am running over microsoft's Cassini server
[the developer's 'baby' web-server - not IIS]. Even if it were live,
it's a subscription only site.

It's a puzzle alright. I tell asp.net to write an &amp; in the code
behind for the gridview (OnRowDataBound event). It gives me a &
But if I tell it to write an &amp; for the asp.net Repeater I get the
&amp; in the html with no problems. [ILLOGICAL]. The asp.net controls
shoudl be consistent!

FF consistently puts the &amp; in the address bar. [WRONG]

The validation software tells me the page with a '&' in the hrefs is OK
[WRONG]

So there are several wrong things going on here all at once.
I guess I should continue this in the asp.net forum.


--

Dec 17 '07 #13
mark4asp wrote:
Martin Honnen wrote:
>mark4asp wrote:
>>If I have, say:
<a href="../page1.aspx?a=1&amp;b=gonow">Go Now</a>
in my html, on clicking the link, will FF give :
blah blah/page1.aspx?a=1&b=gonow
in the address bar?

It's not doing that for me. It gives
blah blah/page1.aspx?a=1&amp;b=gonow
Can you post a URL where that happens?

I'm sorry. It is happening right now on my local web-server. This is an
asp.net 2.0 application I am running over microsoft's Cassini server
[the developer's 'baby' web-server - not IIS]. Even if it were live,
it's a subscription only site.

It's a puzzle alright. I tell asp.net to write an &amp; in the code
behind for the gridview (OnRowDataBound event). It gives me a &
But if I tell it to write an &amp; for the asp.net Repeater I get the
&amp; in the html with no problems. [ILLOGICAL]. The asp.net controls
shoudl be consistent!
Wait a minute--it just hit me. I'm not that familiar with ASP.NET but I
know Visual Studio second-guesses the developer in certain ways. Have
you checked View Source in Firefox to see what's in the source code
being received by the browser? I suspect that when you put a link
control on an ASP page, it assumes you're entering the actual, unencoded
URL and *encodes it for you*. So if you're entering &amp;, it's
converting it to &amp;amp;. Check it and see.
Dec 17 '07 #14

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Gordon - Adelphia | last post: by
50 posts views Thread by Christopher Benson-Manica | last post: by
82 posts views Thread by Buford Early | last post: by
10 posts views Thread by jflash | last post: by
4 posts views Thread by Marijn | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.