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

Double slashes in URLs cause issues #10937

Closed
jonathanKingston opened this issue Apr 22, 2015 · 5 comments
Closed

Double slashes in URLs cause issues #10937

jonathanKingston opened this issue Apr 22, 2015 · 5 comments

Comments

@jonathanKingston
Copy link
Contributor

When I visit a URL with double slashes there are two separate but different issues however I am putting them both here mostly as a question.

Double slash at URL base

When I go to:
http://www.emberaddons.com//?query=asdasd

I get the following error(Along with no application and a blank page):

Uncaught SecurityError: Failed to execute 'replaceState' on 'History': A history state object with URL 'http:/?query=asdasd' cannot be created in a document with origin 'http://www.emberaddons.com'.

This is caused by:

history.pushState({}, '', '//urlhere')

This is reproducible on both Firefox and Chrome (No others tested).

Double slash in the middle of a URL

I'm not certain if this has been introduced recently however a valid URL of: /info/privacy when browsed as: /info//privacy does not match the router route.

Caused by

I have not had time to git bisect which commit caused this issue however it has only happened recently, I suspect knowing how nasty history.pushState can be this is the cause: e23ce41

Prodding @tomdale as this is your commit.

Question

So this could be solved by always removing double slashes before it is routed, which would solve both issues.

However this could quite easily not be desired as dynamic variables Ember might want to be blank, so a route of: /info/:page/:thing/page might want to match if URL is: /info///page. (I personally don't like this and could be solved by some form of keyword too, Catalyst permits this however most frameworks don't).

Thanks

jonathanKingston added a commit to jonathanKingston/ember.js that referenced this issue May 25, 2015
@jacquescrocker
Copy link

i'm running into this issue as well, ended up patching it server side but would be nice if ember didnt explode :)

@jonathanKingston
Copy link
Contributor Author

@railsjedi added the pull request as it passes the tests and works to fix the error however like I said Ember folk might want to fix it differently.
It might not get as lost as a pull anyway.

@tomdale
Copy link
Member

tomdale commented Jul 17, 2015

Could we fix this by always pushing an absolute URL instead of a relative one? E.g. pushState({}, '', 'http://www.example.com//foo') instead of pushState({}, '', '//foo'). Since we have this information, it allows us to eliminate the URL parsing ambiguity by being explicit.

@jonathanKingston
Copy link
Contributor Author

@tomdale yup I think so, just considering the use of a shimmed version of window.location.origin to prefix the URL. As stated above this doesn't fix http://www.example.com/thing//foo as it won't match a route.

Then as @stefanpenner mentioned I will think of a suitable test too.

@rwjblue
Copy link
Member

rwjblue commented Aug 16, 2015

Closing in favor of #11801.

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

4 participants