By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,587 Members | 1,168 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,587 IT Pros & Developers. It's quick & easy.

Problems with "&" changing to "&"

P: n/a
A lot of Firefox users I know, says they have problems with validation
where the ampersand sign has to be written as & to be valid. I don't
have Firefox my self and don't wont to install it only because of this,
so I hope some of you gurus can enlighten me with this :)

In what circumstances can the "&" in the source code be involuntary
changed to "&" by a browser when or other software, when editing and
uploading the file to the web server?

E.g. writing a string like "sc_project=402887&java=0&security"
is changed to "sc_project=402887&java=0&security" when the validator is
processing the code, without the editor doing the change deliberately.

TIA

--
/Arne

Proud User of SeaMonkey. Get your free copy:
http://www.mozilla.org/projects/seamonkey/
May 10 '06 #1
Share this Question
Share on Google+
14 Replies


P: n/a

Arne wrote:
A lot of Firefox users I know, says they have problems with validation


In the route from editor to server to on-line validator, just where
does Firefox (or any browser) have anything to do with it?

Your question, as stated, has too much missing from it to make any
sense.

May 10 '06 #2

P: n/a
In our last episode,
<4c*************@individual.net>,
the lovely and talented Arne
broadcast on comp.infosystems.www.authoring.html:
A lot of Firefox users I know, says they have problems with validation
where the ampersand sign has to be written as &amp; to be valid. I don't
have Firefox my self and don't wont to install it only because of this,
so I hope some of you gurus can enlighten me with this :)
This doesn't make any sense. & should be &amp; anywhere in any html
document unless the & is the beginning of a character reference. Validity
does not depend upon the browser, but is a property the document may or may
not have regardless of the browser. Browser should correctly translate
character references in URLs when they fetch, but so far as I know and I can
tell from testing, Firefox does that.
In what circumstances can the "&amp;" in the source code be involuntary
changed to "&" by a browser when or other software, when editing and
uploading the file to the web server?
I can't make any sense of this. Browsers shouldn't be doing anything to
files they upload, and I never heard of one that did. I'm not sure what
happens if you use a browser function to insert the contents of a file in a
textarea, but that is not the same thing as uploading a file.
E.g. writing a string like "sc_project=402887&amp;java=0&amp;security"
If you write this in a file and save it and then upload the file, the
following should not happen:
is changed to "sc_project=402887&java=0&security" when the validator is
processing the code, without the editor doing the change deliberately.

--
Lars Eighner us****@larseighner.com http://www.larseighner.com/
I have not seen as far as others because giants were standing on my shoulders.
May 10 '06 #3

P: n/a
Once upon a time *Andy Dingley <di*****@codesmiths.com>* wrote:
Arne wrote:
A lot of Firefox users I know, says they have problems with
validation


In the route from editor to server to on-line validator, just where
does Firefox (or any browser) have anything to do with it?

Your question, as stated, has too much missing from it to make any
sense.


Yes, I do belive it's a bit difficult to understand. :)
I'll try with an example as it is described to me.

On a remote visitor tracker site (statcounter.com) when the tracker code
that is to be pasted on a page, is generated using Firefox, the code to
copy is shown in a text box. Part of the code is what I used in my
initial post ("sc_project=402887&java=0&security"). In my browser and
also in IE, this part shows the ampersands as "&amp;".

When I look at the source code for the page where the box with the
generated code is, the ampersand shows as "&amp;amp", but when I
validate the page, the W3C validator also complains about the "&", where
the "&amp;" (or "&amp;amp") should be.

This page is HTML 4.0 Transitional with 9 errors, and most of the errors
(6-7) is because of the ampersand is not shown as "&amp;"

I know it's hard to understand this, and I for sure have no idea. I was
hoping somebody could have some theory what's happening. :)

--
/Arne

Proud User of SeaMonkey. Get your free copy:
http://www.mozilla.org/projects/seamonkey/
May 10 '06 #4

P: n/a
To further the education of mankind, Arne <in*****@domain.invalid>
vouchsafed:
When I look at the source code for the page where the box with the
generated code is, the ampersand shows as "&amp;amp", but when I
validate the page, the W3C validator also complains about the "&", where
the "&amp;" (or "&amp;amp") should be.


What do you mean "should be"? You just said "&amp;amp" was in the source
code. This would display "&amp" in the viewport. So where does the lone
"&" come from? (Btw, note that the "&amp" is incorrect. It should be
"&amp;".)

--
Neredbojias
Infinity has its limits.
May 10 '06 #5

P: n/a
Arne wrote:
Once upon a time *Andy Dingley <di*****@codesmiths.com>* wrote:
Arne wrote:
A lot of Firefox users I know, says they have problems with
validation

In the route from editor to server to on-line validator, just where
does Firefox (or any browser) have anything to do with it?

Your question, as stated, has too much missing from it to make any
sense.


Yes, I do belive it's a bit difficult to understand. :)
I'll try with an example as it is described to me.

On a remote visitor tracker site (statcounter.com) when the tracker code
that is to be pasted on a page, is generated using Firefox, the code to
copy is shown in a text box. Part of the code is what I used in my
initial post ("sc_project=402887&java=0&security"). In my browser and
also in IE, this part shows the ampersands as "&amp;".

When I look at the source code for the page where the box with the
generated code is, the ampersand shows as "&amp;amp", but when I
validate the page, the W3C validator also complains about the "&", where
the "&amp;" (or "&amp;amp") should be.

This page is HTML 4.0 Transitional with 9 errors, and most of the errors
(6-7) is because of the ampersand is not shown as "&amp;"

I know it's hard to understand this, and I for sure have no idea. I was
hoping somebody could have some theory what's happening. :)


I'm still having trouble understanding, but try this: if you have
"&amp;" in your string, and you need it to read as "&amp;" in the
browser, then you need to change it to "&amp;amp;". Not "&amp;amp", as
you wrote twice, but "&amp;amp;". "&amp;amp" will be interpreted as
"&amp", which is indeed invalid.
May 10 '06 #6

P: n/a
Once upon a time *Harlan Messinger* wrote:
Arne wrote:
Once upon a time *Andy Dingley <di*****@codesmiths.com>* wrote:
Arne wrote:
A lot of Firefox users I know, says they have problems with
validation
In the route from editor to server to on-line validator, just where
does Firefox (or any browser) have anything to do with it?

Your question, as stated, has too much missing from it to make any
sense.


Yes, I do belive it's a bit difficult to understand. :)
I'll try with an example as it is described to me.

On a remote visitor tracker site (statcounter.com) when the tracker code
that is to be pasted on a page, is generated using Firefox, the code to
copy is shown in a text box. Part of the code is what I used in my
initial post ("sc_project=402887&java=0&security"). In my browser and
also in IE, this part shows the ampersands as "&amp;".

When I look at the source code for the page where the box with the
generated code is, the ampersand shows as "&amp;amp", but when I
validate the page, the W3C validator also complains about the "&", where
the "&amp;" (or "&amp;amp") should be.

This page is HTML 4.0 Transitional with 9 errors, and most of the errors
(6-7) is because of the ampersand is not shown as "&amp;"

I know it's hard to understand this, and I for sure have no idea. I was
hoping somebody could have some theory what's happening. :)


I'm still having trouble understanding, but try this: if you have
"&amp;" in your string, and you need it to read as "&amp;" in the
browser, then you need to change it to "&amp;amp;". Not "&amp;amp", as
you wrote twice, but "&amp;amp;". "&amp;amp" will be interpreted as
"&amp", which is indeed invalid.


Yes, the "&amp;amp" was a typo from me, but only here. *I* can see
"&amp;amp;" in the source code of the page containing the code (in the
box) for the tracker. In the "web view" mode (the actual page) the code
in the text box shows &amp; for *me*. It's like having "&amp;" in the
page source to see "&" on the page.

But Firefox users see only "&" in the text box that and when they paste
the tracker code to their pages, the code of course don't validate. The
question is why Firefox don't show the tracker code in the box as
SeaMonkey and IE does?

The content in the text box is like plain text in Notepad, but Firefox
is transforming the &amp; to a & even if everything else is as it
should. Firefox users have to add the "amp;" manually to make it valid
code. I guess most can do it, but should not really need to when the
generator is preparing a "ready to copy" code.

And I'm just trying to figure out why this happend only on Firefox. :)

--
/Arne

Proud User of SeaMonkey. Get your free copy:
http://www.mozilla.org/projects/seamonkey/
May 10 '06 #7

P: n/a
Once upon a time *Lars Eighner* wrote:
In our last episode,
<4c*************@individual.net>,
the lovely and talented Arne
broadcast on comp.infosystems.www.authoring.html:
A lot of Firefox users I know, says they have problems with validation
where the ampersand sign has to be written as &amp; to be valid. I don't
have Firefox my self and don't wont to install it only because of this,
so I hope some of you gurus can enlighten me with this :)


This doesn't make any sense. & should be &amp; anywhere in any html
document unless the & is the beginning of a character reference. Validity
does not depend upon the browser, but is a property the document may or may
not have regardless of the browser. Browser should correctly translate
character references in URLs when they fetch, but so far as I know and I can
tell from testing, Firefox does that.
In what circumstances can the "&amp;" in the source code be involuntary
changed to "&" by a browser when or other software, when editing and
uploading the file to the web server?


I can't make any sense of this. Browsers shouldn't be doing anything to
files they upload, and I never heard of one that did. I'm not sure what
happens if you use a browser function to insert the contents of a file in a
textarea, but that is not the same thing as uploading a file.
E.g. writing a string like "sc_project=402887&amp;java=0&amp;security"


If you write this in a file and save it and then upload the file, the
following should not happen:
is changed to "sc_project=402887&java=0&security" when the validator is
processing the code, without the editor doing the change deliberately.

Well, you are not the only one that can't make any sense of this. But
the fact is (as it's told to me anyway) when Firefox users generate the
code(see my other posts) that is "ready to copy" for everybody else (it
seams) they have to manually add the "amp;" part after the "&" to make
it valid code.

If I should see the same in my browsers (SeaMonkey and IE) I may have
suspected e.g. the code generator script, or the firewall. But if the
error is there, why does it affect only Firefox.

If anybody with Firefox in this NG would go to www.statcounter.com and
register for an tracker account, they could see if it happends to them.
However, I don't expect anybody to do it, only because of this. I don't
install Firefox because of it. :)

--
/Arne

Proud User of SeaMonkey. Get your free copy:
http://www.mozilla.org/projects/seamonkey/
May 10 '06 #8

P: n/a
Arne wrote:
Well, you are not the only one that can't make any sense of this. But
the fact is (as it's told to me anyway) when Firefox users generate the
code(see my other posts) that is "ready to copy" for everybody else (it
seams) they have to manually add the "amp;" part after the "&" to make
it valid code.

If I should see the same in my browsers (SeaMonkey and IE) I may have
suspected e.g. the code generator script, or the firewall. But if the
error is there, why does it affect only Firefox.

If anybody with Firefox in this NG would go to www.statcounter.com and
register for an tracker account, they could see if it happends to them.
However, I don't expect anybody to do it, only because of this. I don't
install Firefox because of it. :)


OK, I get the point. For everyone else: StatCounter gives you code to
add a hit counter to your page, and gives you a number of options for
how it should look and operate. Once you've made your selections, it
gives you code like the following, in a TEXTAREA for some reason, so you
can copy and paste it to your web page.

<!-- Start of StatCounter Code -->
<script type="text/javascript" language="javascript">
var sc_project=nnnnnn;
var sc_invisible=0;
var sc_partition=11;
var sc_security="11111111";
</script>

<script type="text/javascript" language="javascript"
src="http://www.statcounter.com/counter/counter.js"></script><noscript><a
href="http://www.statcounter.com/" target="_blank"><img
src="http://c12.statcounter.com/counter.php?sc_project=nnnnnn&java=0&security=1111 111&invisible=0"
alt="free invisible hit counter" border="0"></a> </noscript>
<!-- End of StatCounter Code -->
The above was pasted from Firefox, and you can see that the query string
for counter.php has literal ampersands ("&"). If you View Page Source,
it shows "&amp;".

In IE, the code as displayed in the TEXTAREA has the "&amp;":

src="http://c12.statcounter.com/counter.php?sc_project=nnnnnn&amp;java=0&amp;secur ity=1111111&amp;invisible=0"

View Source shows the underlying code to be "&amp;amp;".

So it looks as though Firefox is throwing in an extra round of replacements.
May 10 '06 #9

P: n/a
Once upon a time *Harlan Messinger* wrote:
Arne wrote:
Well, you are not the only one that can't make any sense of this. But
the fact is (as it's told to me anyway) when Firefox users generate the
code(see my other posts) that is "ready to copy" for everybody else (it
seams) they have to manually add the "amp;" part after the "&" to make
it valid code.

If I should see the same in my browsers (SeaMonkey and IE) I may have
suspected e.g. the code generator script, or the firewall. But if the
error is there, why does it affect only Firefox.

If anybody with Firefox in this NG would go to www.statcounter.com and
register for an tracker account, they could see if it happends to them.
However, I don't expect anybody to do it, only because of this. I don't
install Firefox because of it. :)


OK, I get the point. For everyone else: StatCounter gives you code to
add a hit counter to your page, and gives you a number of options for
how it should look and operate. Once you've made your selections, it
gives you code like the following, in a TEXTAREA for some reason, so you
can copy and paste it to your web page.

<!-- Start of StatCounter Code -->
<script type="text/javascript" language="javascript">
var sc_project=nnnnnn;
var sc_invisible=0;
var sc_partition=11;
var sc_security="11111111";
</script>

<script type="text/javascript" language="javascript"
src="http://www.statcounter.com/counter/counter.js"></script><noscript><a
href="http://www.statcounter.com/" target="_blank"><img
src="http://c12.statcounter.com/counter.php?sc_project=nnnnnn&java=0&security=1111 111&invisible=0"
alt="free invisible hit counter" border="0"></a> </noscript>
<!-- End of StatCounter Code -->
The above was pasted from Firefox, and you can see that the query string
for counter.php has literal ampersands ("&"). If you View Page Source,
it shows "&amp;".

In IE, the code as displayed in the TEXTAREA has the "&amp;":

src="http://c12.statcounter.com/counter.php?sc_project=nnnnnn&amp;java=0&amp;secur ity=1111111&amp;invisible=0"

View Source shows the underlying code to be "&amp;amp;".

So it looks as though Firefox is throwing in an extra round of replacements.


Thank you Harlan, it's a relief to see that it really is as what's told
me and I'm sorry I could not explain it better (as you did). My English
is far from what I wish it to be. :D

Is this something that could be reported as a bug in Firefox, if it's
not done yet? If we don't have any Firefox gurus in this group. :)

--
/Arne

Proud User of SeaMonkey. Get your free copy:
http://www.mozilla.org/projects/seamonkey/
May 10 '06 #10

P: n/a
Harlan Messinger <hm*******************@comcast.net> wrote:
"&amp;amp" will be interpreted as "&amp", which is indeed invalid.


It's not, why would it?

--
David Håsäther
May 10 '06 #11

P: n/a
Once upon a time *David Håsäther* wrote:
Harlan Messinger <hm*******************@comcast.net> wrote:
"&amp;amp" will be interpreted as "&amp", which is indeed invalid.


It's not, why would it?


There is a missing semicolon (;) in the end of the second "amp", so the
first "&amp;" is interpreted as "&" followed by "amp". It was a typo
from me. :)

--
/Arne

Proud User of SeaMonkey. Get your free copy:
http://www.mozilla.org/projects/seamonkey/
May 10 '06 #12

P: n/a
On Wed, 10 May 2006 14:22:41 +0200 Arne <in*****@domain.invalid> wrote:

| On a remote visitor tracker site (statcounter.com) when the tracker code
| that is to be pasted on a page, is generated using Firefox, the code to
| copy is shown in a text box. Part of the code is what I used in my
| initial post ("sc_project=402887&java=0&security"). In my browser and
| also in IE, this part shows the ampersands as "&amp;".
|
| When I look at the source code for the page where the box with the
| generated code is, the ampersand shows as "&amp;amp", but when I
| validate the page, the W3C validator also complains about the "&", where
| the "&amp;" (or "&amp;amp") should be.

If you want the browser to display "&" you code "&amp;".
If you want the browser to display "&amp;" you code "&amp;amp;".
If you want the browser to display "&amp;amp;" you code "&amp;amp;amp;".

If you code "&amp;amp;amp;" it will display as "&amp;amp;".
If you code "&amp;amp;" it will display as "&amp;".
If you code "&amp;" it will display as "&".

It's supposed to do that.

If you have a free standing & all by itself in the HTML, a validator should
complain about it, even though some browsers following the principle of "be
liberal in what you accept" will show it. It may be able to tell the & is
freestanding because no alphanumerics follow it. But in some cases you
might not get what you want even on the liberal browser. The validator is
something that does not follow the "be liberal in what you accept" principle
because it's role is to detect all errors, even if they could function in
some situations.

If you write a program to translate some text where many characters that
would be encoded in special entities in HTML can be freestanding in their
own ASCII or UTF8 or other codes, that program would have to detect all
cases of characters that must be coded in HTML and code them. If I type
in some HTML in plain text <em>like this</em> the expectation is that you
will see the HTML tags if you view the plain text. So encoding this in
HTML means translating the < and > characters to &lt; and &gt; accordingly.

--
-----------------------------------------------------------------------------
| Phil Howard KA9WGN | http://linuxhomepage.com/ http://ham.org/ |
| (first name) at ipal.net | http://phil.ipal.org/ http://ka9wgn.ham.org/ |
-----------------------------------------------------------------------------
May 10 '06 #13

P: n/a
David Håsäther wrote:
Harlan Messinger <hm*******************@comcast.net> wrote:
"&amp;amp" will be interpreted as "&amp", which is indeed invalid.


It's not, why would it?


If your point was to pick on my loose use of the word "valid", I won't
argue.

Other than that, it won't work as intended because it will at best be
treated as four characters rather than as a character entity reference
for a single ampersand character.
May 10 '06 #14

P: n/a
> Is this something that could be reported as a bug in Firefox, if it's
not done yet? If we don't have any Firefox gurus in this group. :)


You could probably report it as a bug in Firefox, but it would be
simpler and probably safer to display your code fragment inside a single
cell HTML table.

--
Steve Swift
http://www.ringers.org.uk
May 18 '06 #15

This discussion thread is closed

Replies have been disabled for this discussion.