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

Inconsistencies with dot-segment normalization #264

Closed
JordanMilne opened this issue Nov 18, 2015 · 3 comments
Closed

Inconsistencies with dot-segment normalization #264

JordanMilne opened this issue Nov 18, 2015 · 3 comments

Comments

@JordanMilne
Copy link
Contributor

It seems like "%2E%2E" should be treated the same as ".." during dot segment normalization, but it isn't:

> URI('/foo/../bar').normalize().toString()
'/bar'
> URI('/foo/%2E%2E/bar').normalize().toString()
'/foo/../bar'

Looks like it's because the normalization of %2E -> . happens after the paths are resolved.

Another one:

// v correct
> URI('/foo/.bar').normalize().toString()
'/foo/.bar'
// v incorrect
> URI('/foo/..bar').normalize().toString()
'bar'
@rodneyrehm
Copy link
Member

It seems like "%2E%2E" should be treated the same as ".." during dot segment normalization, but it isn't:

While Remove Dot Segments does not mention percent encoded values at all, it looks like you're right in the .normalize() context.

 URI('/foo/..bar').normalize().toString()
'bar'

this is definitely a bug.


Are you up to the task and want to send a PR?

There are a bunch of tests for .normalizePath() already.

From today's perspective I'd likely rewrite URI.normalizePath() to base on URI.segmentCoded() and work on the array of segments, rather than string mutation.

@JordanMilne
Copy link
Contributor Author

While Remove Dot Segments does not mention percent encoded values at all, it looks like you're right in the .normalize() context.

It's not clear to me from the RFC what order syntax normalizations should be applied in, but it looks like most browsers apply Percent Encoding Normalization before removing dot segments:

> new URL("http://example.com/foo/%2E%2E/bar").pathname
"/bar"

Are you up to the task and want to send a PR?

Sure thing, might take me 'til the weekend though

@rodneyrehm
Copy link
Member

Sure thing, might take me 'til the weekend though

no worries, take your time :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants