ocpsoft / rewrite

OCPsoft URL-Rewriting Framework
http://ocpsoft.org/rewrite/
Apache License 2.0
188 stars 86 forks source link

tel or mailto links Exception #256

Open djmj opened 6 years ago

djmj commented 6 years ago

I used a PrimeFaces p:link with a phone href value like tel: 0123 456789 and PrimeFaces calls context.getExternalContext().encodeResourceURL(url). So rewrite module is invoked and fails with following exception. Is it a primefaces problem, that they should not call this function in case of a simple href?

java.net.URISyntaxException: Illegal character in opaque part at index 8: 
at java.net.URI$Parser.fail(URI.java:2848)
at java.net.URI$Parser.checkChars(URI.java:3021)
at java.net.URI$Parser.parse(URI.java:3058)
at java.net.URI.<init>(URI.java:588)
at org.ocpsoft.urlbuilder.AddressBuilder.create(AddressBuilder.java:79)
at org.ocpsoft.rewrite.servlet.impl.HttpRewriteWrappedResponse.encodeURL(HttpRewriteWrappedResponse.java:394)
chkal commented 6 years ago

Actually tel:0123 456789 isn't a valid URL/URI. The space character is not allowed. Unfortunately Rewrite currently fails for invalid URLs. You could have the latest snapshots a try. I recently committed some changes which will result in Rewrite handling invalid URLs more gracefully.

djmj commented 6 years ago

Thank you, i did not know that.I will test it later but removing the spaces made it work.

Is it possible to rewrite tel or mailto links at all?

chkal commented 6 years ago

Could work. Not sure. Never tried it. :smile: