Skip to content
This repository was archived by the owner on Oct 8, 2021. It is now read-only.

Commit 0d4e839

Browse files
author
Gabriel Schulhof
committed
Navigation: When submitting a form via GET, strip query off URL before creating new query string. Fixes #5710.
1 parent af46f0e commit 0d4e839

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

js/jquery.mobile.navigation.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -997,7 +997,7 @@ define( [
997997
$.mobile.navreadyDeferred = $.Deferred();
998998
$.mobile._registerInternalEvents = function() {
999999
var getAjaxFormData = function( $form, calculateOnly ) {
1000-
var type, target, url, ret = true, formData, vclickedName;
1000+
var type, target, url, ret = true, formData, vclickedName, method;
10011001
if ( !$.mobile.ajaxEnabled ||
10021002
// test that the form is, itself, ajax false
10031003
$form.is( ":jqmData(ajax='false')" ) ||
@@ -1009,6 +1009,11 @@ define( [
10091009

10101010
target = $form.attr( "target" );
10111011
url = $form.attr( "action" );
1012+
method = ( $form.attr( "method" ) || "get" ).toLowerCase();
1013+
1014+
if ( target ) {
1015+
return false;
1016+
}
10121017

10131018
// If no action is specified, browsers default to using the
10141019
// URL of the document containing the form. Since we dynamically
@@ -1018,6 +1023,13 @@ define( [
10181023
if ( !url ) {
10191024
// Get the @data-url for the page containing the form.
10201025
url = getClosestBaseUrl( $form );
1026+
1027+
// NOTE: If the method is "get", we need to strip off the query string
1028+
// because it will get replaced with the new form data. See issue #5710.
1029+
if ( method === "get" ) {
1030+
url = path.parseUrl( url ).hrefNoSearch;
1031+
}
1032+
10211033
if ( url === documentBase.hrefNoHash ) {
10221034
// The url we got back matches the document base,
10231035
// which means the page must be an internal/embedded page,
@@ -1029,7 +1041,7 @@ define( [
10291041

10301042
url = path.makeUrlAbsolute( url, getClosestBaseUrl( $form ) );
10311043

1032-
if ( ( path.isExternal( url ) && !path.isPermittedCrossDomainRequest( documentUrl, url ) ) || target ) {
1044+
if ( ( path.isExternal( url ) && !path.isPermittedCrossDomainRequest( documentUrl, url ) ) ) {
10331045
return false;
10341046
}
10351047

0 commit comments

Comments
 (0)