Closed Thread Icon

Preserved Topic: unknown entity (validation) when using a '&' in a URL (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=20549" title="Pages that link to Preserved Topic: unknown entity (validation) when using a &amp;#039;&amp;amp;&amp;#039; in a URL (Page 1 of 1)" rel="nofollow" >Preserved Topic: unknown entity (validation) when using a &#039;&amp;&#039; in a URL <span class="small">(Page 1 of 1)</span>\

 
Pugzly
Paranoid (IV) Inmate

From: 127.0.0.1
Insane since: Apr 2000

posted posted 08-06-2002 20:49

I have a line like this:
<B><a class="supersmallred" href="/wanted.php?fid=17">More info</a>

Petskull
Maniac (V) Mad Scientist

From: 127 Halcyon Road, Marenia, Atlantis
Insane since: Aug 2000

posted posted 08-06-2002 21:59

can you escape it with '\'?


Code - CGI - links - DHTML - Javascript - Perl - programming - Magic - http://www.twistedport.com
ICQ: 67751342

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 08-07-2002 11:12

I believe Mr. Max wrote "&amp;amp;" in his post a few times, forgetting that UBB changes that to "&".

So, why can't you embed &amp;amp; into your URLs? most browsers, I believe, will replace them with & and send the correct URL.

mr.maX
Maniac (V) Mad Scientist

From: Belgrade, Serbia
Insane since: Sep 2000

posted posted 08-07-2002 11:21

Ahhh, I made a mistake while editing my post that was above Slime's reply, and accidentally deleted it. Anyway, here's the text of my reply...

Using ampersands in URLs is not valid for quite some time. Everything that starts with "&" sign is treated as HTML entity nowadays (i.e. &amp;nbsp; ), and in your case validator looks for entity called 'fid' (which is in fact a variable name and not a real HTML entity).

Anyway, you have two options here:

1. Forget about validation and leave everything as it is.
2. Change all "&" signs in URLs to "&amp;amp;" or semi-colon ";" and modify PHP configuration, so that it knows that "&amp;amp;" / semi-colon are separators. Options that you need to modify are located in php.ini file and they are entitled "arg_separator.input" and "arg_separator.output"...




[This message has been edited by mr.maX (edited 08-07-2002).]

hlaford
Bipolar (III) Inmate

From: USA! USA! USA!
Insane since: Oct 2001

posted posted 08-07-2002 19:55
quote:
Using ampersands in URLs is not valid for quite some time.



"not valid" is probably too strong a statement. IIS doesn't even recognize the semicolon delimiter. i guess i shouldn't try to back up my arguments using MS software, but i doubt they are alone in their lack of support.

and who decided that semicolons were better than ampersands? what's the reasoning behind the shift?

Pugzly
Paranoid (IV) Inmate

From: 127.0.0.1
Insane since: Apr 2000

posted posted 08-07-2002 20:35
quote:
1. Forget about validation and leave everything as it is.
2. Change all "&" signs in URLs to "&amp;" or semi-colon ";" and modify PHP configuration, so that it knows that "&amp;" / semi-colon are separators. Options that you need to modify are located in php.ini file and they are entitled "arg_separator.input" and "arg_separator.output"...



Hmmm...well, I'll have to settle for #1. I could do #2 for internal URLs, but I have THOUSANDS of links to external pages, and that'll cause the validation to fail, since I can't change those.

Thanks for the info!

mr.maX
Maniac (V) Mad Scientist

From: Belgrade, Serbia
Insane since: Sep 2000

posted posted 08-07-2002 21:36

Hlaford, according to HTML specification, everything that starts with "&" sign should be treated as HTML entity (no matter where it's located). That's why using "&" alone in URLs is not valid. Most web browsers will recover from this fine (i.e. they won't treat text that follows "&" sign as HTML entity), but W3C HTML validator doesn't allow this. In most cases simply replacing all "&" signs with "&amp;amp;" will work fine, because web browsers will translate "&amp;amp;" back to "&" and pass it like that to web server, but as usual YMMV...


Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 08-07-2002 21:38

You are aware, of course, that the *browser* makes the change from &amp;amp; to &? It happens *before* the request is sent. You don't actually have to change the URL of what you're linking to.

For instance, if I made a link to "http://www.somewhere.com/?action=this&amp;amp;query=that" then it would actually be a link to http://www.somewhere.com/?action=this&query=that. It's not like the owner of somewhere.com has to change their server to accept &amp;amp; instead of &.

It's the equivalent of escaping a double quote within a javascript statement:

var mystring = "he said \"hello\"";

In actuality, internally the string is represented without the backslashes. The escaping is just for the sake of input, after that they're forgotten about.

Pugzly
Paranoid (IV) Inmate

From: 127.0.0.1
Insane since: Apr 2000

posted posted 08-07-2002 22:32

True, and I COULD write a function to change external links.......

Sure - just give me MORE work....

Petskull
Maniac (V) Mad Scientist

From: 127 Halcyon Road, Marenia, Atlantis
Insane since: Aug 2000

posted posted 08-08-2002 14:47

yeah, damnit! get to work, slave!
*cracks whip*


Code - CGI - links - DHTML - Javascript - Perl - programming - Magic - http://www.twistedport.com
ICQ: 67751342

« BackwardsOnwards »

Show Forum Drop Down Menu