Mercurial Hosting > luan
comparison src/luan/webserver/RequestParser.java @ 1221:b99947af8b79
better path parsing
| author | Franklin Schmidt <fschmidt@gmail.com> |
|---|---|
| date | Sun, 25 Mar 2018 17:13:11 -0600 |
| parents | 220228bf1af9 |
| children | 275d1b52dbce |
comparison
equal
deleted
inserted
replaced
| 1220:4721c482c86b | 1221:b99947af8b79 |
|---|---|
| 69 | 69 |
| 70 private void parsePath() throws ParseException { | 70 private void parsePath() throws ParseException { |
| 71 int start = parser.currentIndex(); | 71 int start = parser.currentIndex(); |
| 72 if( !parser.match('/') ) | 72 if( !parser.match('/') ) |
| 73 throw new ParseException(parser,"bad path"); | 73 throw new ParseException(parser,"bad path"); |
| 74 while( safePathChar() || parser.anyOf("&=") ); | 74 while( parser.noneOf(" ?#") ); |
| 75 request.path = urlDecode( parser.textFrom(start) ); | 75 request.path = urlDecode( parser.textFrom(start) ); |
| 76 } | 76 } |
| 77 | 77 |
| 78 private void parseQuery() throws ParseException { | 78 private void parseQuery() throws ParseException { |
| 79 do { | 79 do { |
| 94 } while( parser.match('&') ); | 94 } while( parser.match('&') ); |
| 95 } | 95 } |
| 96 | 96 |
| 97 private boolean queryChar() { | 97 private boolean queryChar() { |
| 98 return parser.noneOf("=&# \t\n\f\r\u000b"); | 98 return parser.noneOf("=&# \t\n\f\r\u000b"); |
| 99 } | |
| 100 | |
| 101 // where did I get this? | |
| 102 private boolean safePathChar() { | |
| 103 return parser.inCharRange('A','Z') | |
| 104 || parser.inCharRange('a','z') | |
| 105 || parser.inCharRange('0','9') | |
| 106 || parser.anyOf("-._~:/[]@!$'()*+,;`.%") | |
| 107 ; | |
| 108 } | 99 } |
| 109 | 100 |
| 110 private void parseProtocol() throws ParseException { | 101 private void parseProtocol() throws ParseException { |
| 111 int start = parser.currentIndex(); | 102 int start = parser.currentIndex(); |
| 112 if( !( | 103 if( !( |
