Permalink
Browse files

Navigation: When submitting a form via GET, strip query off URL befor…

…e creating new query string. Fixes #5710.
  • Loading branch information...
gabrielschulhof committed Mar 14, 2013
1 parent af46f0e commit 0d4e839782c8574799b31ff222f80c683dccac88
Showing with 14 additions and 2 deletions.
  1. +14 −2 js/jquery.mobile.navigation.js
@@ -997,7 +997,7 @@ define( [
$.mobile.navreadyDeferred = $.Deferred();
$.mobile._registerInternalEvents = function() {
var getAjaxFormData = function( $form, calculateOnly ) {
var type, target, url, ret = true, formData, vclickedName;
var type, target, url, ret = true, formData, vclickedName, method;
if ( !$.mobile.ajaxEnabled ||
// test that the form is, itself, ajax false
$form.is( ":jqmData(ajax='false')" ) ||
@@ -1009,6 +1009,11 @@ define( [
target = $form.attr( "target" );
url = $form.attr( "action" );
method = ( $form.attr( "method" ) || "get" ).toLowerCase();
if ( target ) {

This comment has been minimized.

Show comment
Hide comment
@TrejGun

TrejGun Mar 15, 2013

may be this condition should be after 'target' definition?

@TrejGun

TrejGun Mar 15, 2013

may be this condition should be after 'target' definition?

This comment has been minimized.

Show comment
Hide comment
@gabrielschulhof

gabrielschulhof Mar 15, 2013

Contributor

Good point - same for url.

@gabrielschulhof

gabrielschulhof Mar 15, 2013

Contributor

Good point - same for url.

return false;
}
// If no action is specified, browsers default to using the
// URL of the document containing the form. Since we dynamically
@@ -1018,6 +1023,13 @@ define( [
if ( !url ) {
// Get the @data-url for the page containing the form.
url = getClosestBaseUrl( $form );
// NOTE: If the method is "get", we need to strip off the query string
// because it will get replaced with the new form data. See issue #5710.
if ( method === "get" ) {
url = path.parseUrl( url ).hrefNoSearch;
}
if ( url === documentBase.hrefNoHash ) {
// The url we got back matches the document base,
// which means the page must be an internal/embedded page,
@@ -1029,7 +1041,7 @@ define( [
url = path.makeUrlAbsolute( url, getClosestBaseUrl( $form ) );
if ( ( path.isExternal( url ) && !path.isPermittedCrossDomainRequest( documentUrl, url ) ) || target ) {
if ( ( path.isExternal( url ) && !path.isPermittedCrossDomainRequest( documentUrl, url ) ) ) {
return false;
}

0 comments on commit 0d4e839

Please sign in to comment.