This repository has been archived by the owner on Oct 8, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Navigation: Correctly (un)escape data-url all throughout the code
Also removes code dealing with nested list URL tokens (subPageUrlKey) The initial bug was regarding the need to use selector-escaping when looking for pages inside the DOM via their data-url attribute, because the the data-url may contain "weird" characters like parantheses, single, and double quotes. During the process of fixing this it became clear that the data-url attribute can sometimes end up having a URL-encoded value - but not always. This makes proper string comparison, much less selector-escaping, impossible. So, it became necessary to require that data-url never be url-encoded. Conversely, the URL that ends up in the location when using replaceState() must be URL-encoded, otherwise, upon deep linking, one may end up with an invalid URL. For example, if the URL contains an actual percent sign, and the URL is placed in the location via replaceState(), the percent sign must be URL-encoded in order for deep-linking to work. Below are the original commit messages that have been squashed: Pagecontainer: Escape dataUrl when trying to find page based on it Navigation: Make sure location is encoded when going to a funky page Pagecontainer: Test that _find() throws not when looking for weird URLs Init: Correctly assign data-url for initial page Init: Make sure "data-url" attribute for initial page is decoded Pagecontainer: Decode URI when assigning to "data-url" during _parse() Pagecontainer: Use decoded URL to build selector for data-url Pagecontainer: Call convertUrlToDataUrl() via _createDataUrl() Path: Always uri-decode when computing dataUrl Pagecontainer: Remove extra decoding step, now part of _createDataUrl() This also removes the possibility that a URL gets double-decoded. Pagecontainer: Test behavior of _find() in the face of weird URLs Navigation: Use data-url retrieved from Ajax request in its encoded form Pagecontainer: Pass encoded URL to $.mobile.navigate() Init: Rename JS file with spaces in it (cherry picked from commit e412102) Closes gh-7474 Fixes gh-1383
- Loading branch information
Gabriel Schulhof
committed
Sep 4, 2014
1 parent
c4623d0
commit d3a412e
Showing
12 changed files
with
180 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
tests/integration/navigation/100%test/behind-the-percent.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
</head> | ||
<body> | ||
<div data-nstest-role="page"><div id="percentPageChild"></div></div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<title>jQuery Mobile Init Test Suite</title> | ||
|
||
<script src="../../../external/requirejs/require.js"></script> | ||
<script src="../../../js/requirejs.config.js"></script> | ||
<script src="../../requirejs.config.js"></script> | ||
<script src="../../../js/jquery.tag.inserter.js"></script> | ||
<script src="../../jquery.setNameSpace.js"></script> | ||
<script src="../../jquery.testHelper.js"></script> | ||
|
||
<link rel="stylesheet" href="../../../css/themes/default/jquery.mobile.css" /> | ||
<link rel="stylesheet" href="../../../external/qunit/qunit.css"/> | ||
<link rel="stylesheet" href="../../jqm-tests.css"/> | ||
<script src="../../../external/qunit/qunit.js"></script> | ||
<script> | ||
$.testHelper.asyncLoad([ | ||
[ "weird_file_name_core.js" ], | ||
[ "jquery.mobile.init" ] | ||
]); | ||
</script> | ||
|
||
<script src="../../swarminject.js"></script> | ||
</head> | ||
<body> | ||
|
||
<div id="qunit"></div> | ||
|
||
<div data-nstest-role="page"></div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
( function() { | ||
|
||
$( document ).on( "mobileinit", function() { | ||
var origParseLocation = $.mobile.path.parseLocation, | ||
origInitializePage = $.mobile.initializePage; | ||
|
||
// Overwrite parseLocation with a version that always urlencodes the name of the tests file | ||
$.mobile.path.parseLocation = function() { | ||
var parsedLocation = origParseLocation.apply( this, arguments ), | ||
returnValue = {}; | ||
|
||
// Make sure the location bits appear urlEncoded | ||
$.each( parsedLocation, function( key, value ) { | ||
returnValue[ key ] = | ||
value.replace( /weird file name-tests/g, "weird%20file%20name-tests" ); | ||
}); | ||
|
||
return returnValue; | ||
}; | ||
|
||
// Overwrite initializePage with a version that restores both itself and parseLocation after | ||
// one call to itself | ||
$.mobile.initializePage = function() { | ||
|
||
$.mobile.intializePage = origInitializePage; | ||
$.mobile.path.parseLocation = origParseLocation; | ||
|
||
return origInitializePage.apply( this, arguments ); | ||
}; | ||
}); | ||
|
||
test( "data-url for initial page is urldecoded", function() { | ||
deepEqual( | ||
!!$( ":mobile-page" ) | ||
.attr( "data-" + $.mobile.ns + "url" ) | ||
.match( /weird%20file%20name/ ), | ||
false, | ||
"Value of 'data-url' attribute is not urlencoded" ); | ||
}); | ||
|
||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters