Forum Moderators: open

Message Too Old, No Replies

'Value' string fails after URL encoding (sometimes)

         

ThomasAJ

7:14 am on Feb 13, 2006 (gmt 0)

10+ Year Member



I use the escape() function to do URL encoding on a text string (lets call it 'original text string') and use the resultant string as a VALUE in a NAME/VALUE pair. However sometimes the Apache server fails with a message about invalid URL characters when it tries to use it in a NAME/VALUE pair situation (whatever that is called? I don't do this stuff often).

The 'original text string' contained ellipses (...) which seemed to be encode as '%u2026'. There are other 'original text strings' that fail but I have not yet tracked down the culprit characters.

How can I get rid of unaccepatable characters BEFORE encoding?

Dijkgraaf

8:02 am on Feb 13, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Is your only option JavaScript?
If you can use server side scripts then you are better off use an urlencode functions that will do a better job.

ThomasAJ

12:19 am on Feb 14, 2006 (gmt 0)

10+ Year Member



Yes javascipt is the only option.

Dijkgraaf

9:26 am on Feb 14, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well you could write a JavaScript routine that would go through a string and strip out any non-safe characters.
Do a search for safe characters in URL and you will find some sites that discuss what is and isn't allowed in a URL.

kaled

11:53 am on Feb 14, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Have you specified a charset, if so which one?

Does the page validate?

Kaled.

Dijkgraaf

9:09 pm on Feb 14, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can't use Charsets in URLs, that is part of the problem.

kaled

10:11 pm on Feb 14, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It's possible that the javascript escape function uses the page's charset for some chars. Certainly, when forms are submitted, the charset can make a difference.

Kaled.