Invalid characters for http url

Can someone tell me what are the invalid characters for the HTTP url and the best way to test them in Java. What I'm looking for is a URLString check in the format URL: http (s): // ip: port / URLString

Thanks in advance.

+4
source share
4 answers

According to RFC 1738, the following are considered unsafe:

  • <and> are separators around URLs in free text
  • "(double quote) - limits URLs on some systems
  • - restricts the URL from the fragment / anchor identifier that can follow it

  • % - used to indicate character encodings

Common unsafe characters: {} | \ ^ ~ [] `

Edit:

Not a duplicate, but includes some thoughts on validation in Java: URL validation in java

+1
source

You can use any unicode characters you want as long as they are encoded in%. Explicit reserved characters are defined in section 2.2 of RFC3986: http://tools.ietf.org/html/rfc3986#section-2

From the doc:

reserved = gen-delims / sub-delims gen-delims = ":" / "/" / "?" / "#" / "[" / "]" / "@" sub-delims = "!" / "$" / "&" / "'" / "(" / ")" / "*" / "+" / "," / ";" / "=" 
+3
source

Read more on RFC1738 Page 2 and Page 3 in the link.

0
source

How about using UrlValidator ? The isValidPath method is probably useful. :)

0
source

All Articles