Permalink
Browse files

for HTML4 browsers, assume the URI passed to pushState() is URI-encod…

…ed, and make sure that every character is encoded like document.URL
  • Loading branch information...
1 parent 50c883e commit 036ac100057982e5ba13b4a374608acc7ad1d044 @andrew-sayers--slando committed Oct 19, 2011
Showing with 11 additions and 1 deletion.
  1. +11 −1 scripts/uncompressed/history.html4.js
@@ -454,7 +454,7 @@
// Push the new HTML5 State
//History.debug('History.onHashChange: success hashchange');
- History.pushState(currentState.data,currentState.title,currentState.url,false);
+ History.pushState(currentState.data,currentState.title,encodeURI(currentState.url),false);
// End onHashChange closure
return true;
@@ -473,6 +473,11 @@
History.pushState = function(data,title,url,queue){
//History.debug('History.pushState: called', arguments);
+ // We assume that the URL passed in is URI-encoded, but this makes
+ // sure that it's fully URI encoded; any '%'s that are encoded are
+ // converted back into '%'s
+ url = encodeURI(url).replace(/%25/g, "%");
+
// Check the State
if ( History.getHashByUrl(url) ) {
throw new Error('History.js does not support states with fragment-identifiers (hashes/anchors).');
@@ -550,6 +555,11 @@
History.replaceState = function(data,title,url,queue){
//History.debug('History.replaceState: called', arguments);
+ // We assume that the URL passed in is URI-encoded, but this makes
+ // sure that it's fully URI encoded; any '%'s that are encoded are
+ // converted back into '%'s
+ url = encodeURI(url).replace(/%25/g, "%");
+
// Check the State
if ( History.getHashByUrl(url) ) {
throw new Error('History.js does not support states with fragment-identifiers (hashes/anchors).');

0 comments on commit 036ac10

Please sign in to comment.