User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.165 Safari/535.19 Steps to reproduce: 1) Go to a url with #'" at the end 2) Open your console and evaluate location.href Actual results: The output will end in #%27%22 Expected results: I don't think it should escape these characters. Chrome and Internet Explorer do not escape them. encodeURIComponent() does not escape them. Only escape() escapes them. Is there a spec on what characters should be escaped in location.href?
Oops, my bad. encodeURIComponent escapes quotes but not apostrophes. It's apostrophes that I am really concerned about. encodeURI and encodeURIComponent do not encode quotes, but location.href does, which seems wrong to me.
Summary: Firefox escapes quotes (") and apostrophes (') in the hash in location.href → Firefox escapes apostrophes (') in the hash in location.href
Marking dup, but just to save you reading time this was a change from bug 376844.
Status: UNCONFIRMED → RESOLVED
Last Resolved: 6 years ago
Resolution: --- → DUPLICATE
Duplicate of bug: 407172
Darn, looks like this is something people are waffling on. "This is not consistent with RFC2396 but I cannot think of any case where it will break something." -- Wladimir Palant It breaks AngularJS, which attempts to construct the URL based on its components and defined escaping rules. It succeeds on all browsers except Firefox because Firefox's escaping rules are different. I had to patch my copy of Angular to account for this inconsistency. I suppose it's not a big problem, but inconsistencies are no fun in web programming.
You need to log in before you can comment on or make changes to this bug.