Can anyone tell me what are the invalid characters for HTTP URL and the best way to validate the same in Java. What I am looking for is URLString validation in the URL format: http(s)://ip:port/URLString
Thanks in advance.
A URL in your data feed is badly formed or contains invalid characters. There are several common reasons why you might receive this error: Your URLs contain spaces or symbols.
These characters are "{", "}", "|", "\", "^", "~", "[", "]", and "`". All unsafe characters must always be encoded within a URL.
Thus, only alphanumerics, the special characters " $-_. +! *'(), ", and reserved characters used for their reserved purposes may be used unencoded within a URL.
There are only certain characters that are allowed in the URL string, alphabetic characters, numerals, and a few characters ; , / ? : @ & = + $ - _ . ! ~ * ' ( ) # that can have special meanings.
You can use any unicode characters you want, as long as they are % encoded. The explicitly reserved characters are defined in section 2.2 of RFC3986: https://www.rfc-editor.org/rfc/rfc3986#section-2
From the document:
reserved = gen-delims / sub-delims
gen-delims = ":" / "/" / "?" / "#" / "[" / "]" / "@"
sub-delims = "!" / "$" / "&" / "'" / "(" / ")"
/ "*" / "+" / "," / ";" / "="
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With