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

Unexpected page router navigate in Mozilla #4132

Open
arevenok opened this issue Apr 5, 2017 · 3 comments
Open

Unexpected page router navigate in Mozilla #4132

arevenok opened this issue Apr 5, 2017 · 3 comments
Labels

Comments

@arevenok
Copy link

arevenok commented Apr 5, 2017

If there any German, Japanese etc. and any symbols like these in the url, getHash method returns incorrect result because of wrong encoding of this symbols in the Firefox browser, see window.location.href. And because of this navigate method is triggered.

Navigate method is triggered because we have different urls in checkUrl function in the
var current = this.getFragment(); and in this.fragment values.

Example in Mozilla:

Result wich is returned by getFragment function:
https://example.com/example?filterBy_city=%E5%A4%A7%E9%98%AA%2C%E5%AF%8C%E5%B1%B1%2C%E5%B2%A1%E5%B1%B1

this.fragment value:
https://example.com/example?filterBy_city=大阪%2C富山%2C岡山

Example in Chrome

Result wich is returned by getFragment function:
https://example.com/example?filterBy_city=大阪%2C富山%2C岡山

this.fragment value:
https://example.com/example?filterBy_city=大阪%2C富山%2C岡山

I find the solution for it using decodeFragment in the getHash method:
image
Would it be safely to do it this way?

@jashkenas
Copy link
Owner

See previous tickets: I believe there was a bug in certain versions of Firefox that made this impossible to work around in Backbone itself.

Do you have a specific change you'd like to propose here?

@Daniel-Alonso-Exabeam
Copy link

Daniel-Alonso-Exabeam commented Dec 12, 2017

Hello, I have encountered this same issue while developing for my company and I have investigated it thoroughly. (I have also seen some previous tickets about this.)

Here's my conclusion on this issue:
I believe that the root of the problem is located in these lines of code within the navigate function:
image
There is no point in decoding the fragment for matching, because this._updateHash() is setting the hash as encoded (as it should), and this.fragment should match parity by being set as encoded as well. However, currently this.fragment is being set as decoded instead, so checkUrl will always trigger a loadUrl for any url with special characters.
The solution is to simply not decode the fragment.

If this solution is chosen, then getPath, getHash, or getFragment should NOT be doing any decoding. All fragment matching should be done using encoded format. If fragment matching is done in a decoded format, it would not be compatible with Firefox.

Let me know what you guys think! If it sounds good, I'll make a PR.

@jgonggrijp
Copy link
Collaborator

@Daniel-Alonso-Exabeam I realize this reply is rather late, but you are welcome to submit a PR.

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

No branches or pull requests

4 participants