Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not parse encoded and reserved charactor mixed path #37

Open
junkmb opened this issue Mar 26, 2020 · 0 comments
Open

Could not parse encoded and reserved charactor mixed path #37

junkmb opened this issue Mar 26, 2020 · 0 comments

Comments

@junkmb
Copy link

junkmb commented Mar 26, 2020

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

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%[email protected]
// 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%[email protected]
// expect: {username: %E3%82%B5%E3%83%B3%E3%83%97%E3%83%[email protected]}

I think this caused by regexp in _Compiler._compilePath method does not include % character.
For this reason, template expansion/parsing with + operator seems to have no reversibility as below.

Additional: Example based on RFC6570 1.2. Level 2

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!}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant