Opened 10 years ago

Closed 10 years ago

#9969 closed defect (fixed)

[patch][ccla]dojo.hash doesn't detect query parameters after the hash in IE6

Reported by: miksago Owned by: anonymous
Priority: high Milestone: 1.4
Component: General Version: 1.3.2
Keywords: Cc: Rob Retchless, Adam Peller, Ben Lowery
Blocked By: Blocking:

Description

Fix for IE6 bug involving question mark in hash.

If a question mark appears in a URL fragment, IE6 will exclude the question mark and everything after it from window.location.hash. For example, given the location:

http://example.com/#/docs?page=1&per_page=10

The value of window.location.hash will be:

#/docs

This bug is based on a patch from [Sammy] http://github.com/quirkey/sammy/commit/7e900af9a246212c162788818e696f66f878c10f

Attachments (3)

hash.patch.2.js (665 bytes) - added by miksago 10 years ago.
Updated patch, thanks for blowery
hash.patch.js (636 bytes) - added by miksago 10 years ago.
Updated patch, thanks for blowery
hash.patch (516 bytes) - added by Adam Peller 10 years ago.
Patch from Rob Retchless. Also, does decode unconditionally to avoid browser detection.

Download all attachments as: .zip

Change History (11)

comment:1 Changed 10 years ago by miksago

See attached file, hash.patch.js

Should be fixed.

Changed 10 years ago by miksago

Attachment: hash.patch.2.js added

Updated patch, thanks for blowery

Changed 10 years ago by miksago

Attachment: hash.patch.js added

Updated patch, thanks for blowery

comment:2 Changed 10 years ago by James Burke

Cc: Rob Retchless Adam Peller added

Asking retchless to comment. I think an alternate, shorter fix would be using location.href.split("#")[1] to get the hash value. I also thought retchless purposely avoided decoding the values.

comment:3 Changed 10 years ago by Rob Retchless

Small issue with this patch - it seems to be including the # symbol as part of the return string.

location.href.split("#")[1] would only work if there was only one # in the URL. It's possible that there could be multiple hashes in the URL.

So I'm thinking something like this:

var h = location.href, i = h.indexOf("#");
h = (i>=0) ? h.substring(i+1) : "";
return dojo.isMoz ? h : decodeURIComponent(h);	

Patch incoming.

comment:4 Changed 10 years ago by Rob Retchless

You're right James, we should definitely avoid decoding in this case.

We were decoding before because Firefox automatically decodes the location.hash string and we wanted cross-browser consistency. Now that we're using location.href, this is no longer the case, making the browser sniff and decode unnecessary.

Changed 10 years ago by Adam Peller

Attachment: hash.patch added

Patch from Rob Retchless. Also, does decode unconditionally to avoid browser detection.

comment:5 Changed 10 years ago by Adam Peller

Cc: Ben Lowery added

comment:6 Changed 10 years ago by Adam Peller

Milestone: tbd1.4
Summary: dojo.hash doesn't detect query parameters after the hash in IE6[patch][ccla]dojo.hash doesn't detect query parameters after the hash in IE6

comment:7 Changed 10 years ago by Ben Lowery

+1 on not decoding any more. It'll actually make a lot of common cases work (embedded / and ? for example).

comment:8 Changed 10 years ago by James Burke

Resolution: fixed
Status: newclosed

(In [20469]) Applying patch from Rob Retchless, CLA. Fixes #9969

Note: See TracTickets for help on using tickets.