The problem I encountered was with not validating URI's with commas, but looking at the code shows that the regex is also too lax. libxml2 has a good implementation and its MIT license would allow using their code instead.