I noticed the following exception is thrown in my Play! application running on Tomcat:
javax.servlet.ServletException: java.net.URISyntaxException: Illegal character in path at index 35: /K-NAAN/lyrics/Is-Anybody-Out-There[]-lyrics/3807088
play.server.ServletWrapper.service(ServletWrapper.java:157)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
root cause
java.net.URISyntaxException: Illegal character in path at index 35: /K-NAAN/lyrics/Is-Anybody-Out-There[]-lyrics/3807088
java.net.URI$Parser.fail(Unknown Source)
java.net.URI$Parser.checkChars(Unknown Source)
java.net.URI$Parser.parseHierarchical(Unknown Source)
java.net.URI$Parser.parse(Unknown Source)
java.net.URI.<init>(Unknown Source)
play.server.ServletWrapper.parseRequest(ServletWrapper.java:241)
play.server.ServletWrapper.service(ServletWrapper.java:132)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
According to this thread square brackets aren't valid characters in an URI, and it's the client's responsibility to encode them? I get that exception in Chrome on MacOS, but not on Firefox, which seems to imply Chrome doesn't encode them. What's worse, I'm pretty sure googlebot also encounters that exception.
What's the right course of action here?
Can I tweak Tomcat to somehow accept or encode square brackets? Or is it a bug or behavior in Play?
Or should I just make sure that every single link to my pages has square brackets URL-encoded? Possible on my own website, of course, but not so much for external links.