I don't really need to validate a URL. I just need to make sure the characters being sent in are valid characters we'd see in a complex URL string. Among other precautions already in place, I'm trying my best to prevent against injection.
This is the regex I'm using now:
eregi("[^(http|https)\://[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(:[a-zA-Z0-9]*)?/?([a-zA-Z0-9\-\._\?\,\'/\\\+&%\$#\=~])*$]", $url )
That is working well until we get to the & symbol.
This URL:
http://www.something.com/test.php?a=b&c=d
Comes out like this:
http://www.something.com/test.php?a=b
Can someone adjust what I have OR show me a better example to simply keep unwanted characters out of the URL string?