NanoHttpd / nanohttpd

Tiny, easily embeddable HTTP server in Java.
http://nanohttpd.org
BSD 3-Clause "New" or "Revised" License
6.92k stars 1.69k forks source link

Route does not match params with accent letters #522

Open lfkpoa opened 5 years ago

lfkpoa commented 5 years ago

Hi,

I'm trying to use RouterNanoHTTPD and define a route like: addRoute("/api/:schema/:table", SqlTableScanHandler.class); However, it does not match when the url has non ascii characters (accent characters), like in: http://localhost:8080/api/user/joão Looking into the source code I noticed that the regexp pattern that replaces the params does not allow it. The pattern is: ([A-Za-z0-9\\-\\._~:/?#\\[\\]@!\\$&'\\(\\)\\*\\+,;=\\s]+) I wonder why not replace by a simple pattern that accepts any characters like: (.+?) Or eventually by a pattern that accepts all characters except for some that may not be allowed?

LordFokas commented 5 years ago

First of all, I'm really glad that this seems to be an HTTP library of choice in the land of the Tugas 😃 👍

That being said, what we must do is check the appropriate RFCs (groan) and see what we should be doing in this case, then fix everything that has been half-assed (spoiler: probably a lot of stuff, NanoHTTPD was always mostly developed that way)

Do you want to look into that? (RFCs are boring, but you might learn a few interesting things)