Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > Valid characters in GET data

Reply
Thread Tools

Valid characters in GET data

 
 
David Segall
Guest
Posts: n/a
 
      12-20-2007
I want to encode a string that will be used as a GET data parameter
but the algorithm I have can produce the characters "/", "+" and "="
in addition to alphanumeric characters. Those characters don't have a
named entity in my HTML text book so I believe they can be used
without further encoding. Can they? In other words, is the URL
<http://example.com?myparam=four/two+3=5> valid? For extra credit ,
where should I have looked to find the definitive answer to this
question?
 
Reply With Quote
 
 
 
 
Harlan Messinger
Guest
Posts: n/a
 
      12-20-2007
David Segall wrote:
> I want to encode a string that will be used as a GET data parameter
> but the algorithm I have can produce the characters "/", "+" and "="
> in addition to alphanumeric characters. Those characters don't have a
> named entity in my HTML text book so I believe they can be used
> without further encoding. Can they? In other words, is the URL
> <http://example.com?myparam=four/two+3=5> valid? For extra credit ,
> where should I have looked to find the definitive answer to this
> question?


URLs are not HTML. They have their own syntax. In particular, the plus
and equals signs have special meanings in a query string: the plus sign
is interpreted as a space character and the equals sign is used to
create a key/value association as you did in your own example,
associating the key "myparam" with the value "four/two+5=5".

The characters that have special meaning in a query string or that
delimit the query string from other parts of the URL are the ones in the
set {=?&;#%+}. When you use want to use any of these as an ordinary
character, encode it as %nn where nn is the hexadecimal ASCII code for
the character. An embedded space can be encoded as either %20 or a plus
sign.

See http://en.wikipedia.org/wiki/Percent-encoding.
 
Reply With Quote
 
 
 
 
Toby A Inkster
Guest
Posts: n/a
 
      12-20-2007
David Segall wrote:

> I want to encode a string that will be used as a GET data parameter but
> the algorithm I have can produce the characters "/", "+" and "=" in
> addition to alphanumeric characters. Those characters don't have a named
> entity in my HTML text book so I believe they can be used without
> further encoding.


Wrong. All three have special meanings in form data, so although a URL
like "http://example.com?myparam=four/two+3=5" is perfectly valid, your
webserver and/or scripting language may interpret it differently to how
you might expect.

For example, the '+' may be decoded to a space character before you get
your hands on it.

URLs such as this would typically need to be hex-encoded to avoid being
interpreted:

http://example.com?myparam=four%2Ftwo%2B3%3D5

- and * would probably be safer than + and /. < or > would be safer than =.

--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.17.14-mm-desktop-9mdvsmp, up 13 days, 3:12.]

Sharing Music with Apple iTunes
http://tobyinkster.co.uk/blog/2007/1...tunes-sharing/
 
Reply With Quote
 
Toby A Inkster
Guest
Posts: n/a
 
      12-20-2007
David Segall wrote:

> where should I have looked to find the definitive answer to this
> question?


Mostly:

HTML 4.01 Specification: 17.13 Form submission
http://www.w3.org/TR/html401/interac...s.html#h-17.13

Supporting documents:

RFC 2616: Hypertext Transfer Protocol -- HTTP/1.1
http://www.ietf.org/rfc/rfc2616.txt

RFC 1738: Uniform Resource Locators (URL)
http://www.ietf.org/rfc/rfc1738.txt

--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.17.14-mm-desktop-9mdvsmp, up 13 days, 3:18.]

Sharing Music with Apple iTunes
http://tobyinkster.co.uk/blog/2007/1...tunes-sharing/
 
Reply With Quote
 
Toby A Inkster
Guest
Posts: n/a
 
      12-21-2007
Harlan Messinger wrote:

> URLs are not HTML. They have their own syntax.


But of course, URLs represented in HTML have to both conform to the URL
syntax rules, *plus* HTML syntax rules. (The trick is to apply the URL
rules first, such as percent-encoding, and *then* apply HTML rules, like
representing ampersands as "&amp;".)

--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.17.14-mm-desktop-9mdvsmp, up 13 days, 23:04.]

Sharing Music with Apple iTunes
http://tobyinkster.co.uk/blog/2007/1...tunes-sharing/
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
The data does not correspond to valid JSON. Parameter name: data Nanda ASP .Net 2 08-16-2009 08:16 PM
Disputing Cookie.py's definition of valid characters Joshua Kugler Python 0 12-12-2008 02:47 AM
'' is not a valid name. Make sure that it does not include invalid characters or punctuation and that it is not too long. rote ASP .Net 2 01-23-2008 03:07 PM
How to convert HTML special characters to the real characters with a Java script Stefan Mueller HTML 3 07-23-2006 10:09 PM
Convert Raw Text Escaped Characters to Characters nicholas.wakefield@gmail.com Java 2 07-11-2005 09:17 PM



Advertisments