Could not parse encoded and reserved charactor mixed path
- Dominant language
- Dart
- Stars
- 80
- Forks
- 42
- PR merge metrics
- No merged PRs in 30d
Description
Hi,
I had a problem when parsing URL which mixture of UTF-8 encoded and reserved URI charactors.
### Version
- dart: 2.5.0
- uri: 0.11.3+1
### Example
username: サンプル@example.com
```dart
var uri = Uri.parse("https://example.com/users/サンプル@example.com");
print("uri: $uri");
// uri: https://example.com/users/%E3%82%B5%E3%83%B3%E3%83%97%E3%83%AB@example.com
// Encoded like this automatically
var template = UriTemplate("/users/{+username}");
var parser = UriParser(template);
var params = parser.parse(uri);
print("params: $params");
// ParseException: /users/{+username} does not match https://example.com/users/%E3%82%B5%E3%83%B3%E3%83%97%E3%83%AB@example.com
// expect: {username: %E3%82%B5%E3%83%B3%E3%83%97%E3%83%AB@example.com}
```
I think this caused by [regexp in `_Compiler._compilePath` method](https://github.com/google/uri.dart/blob/master/lib/src/uri_template.dart#L398) does not include `%` character.
For this reason, template expansion/parsing with `+` operator seems to have no reversibility as below.
### Additional: Example based on [RFC6570](https://tools.ietf.org/html/rfc6570) 1.2. `Level 2`
```dart
var template = UriTemplate("/{+hello}");
var parser = UriParser(template);
var uri = parser.expand({"hello": "Hello World!"});
print("uri: $uri");
// uri: /Hello%20World!
var params = parser.parse(uri);
print("params: $params");
// params: {hello: Hello} <- expect: {hello: Hello%20World!}
```
Contributor guide
Assessment
This issue has not been assessed yet.