Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Duplicated form parameters when form is submitted repeatedly #5710

Closed
mikez302 opened this Issue · 3 comments

2 participants

@mikez302

I have a page that looks like this:

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8"/>
        <title>Duplicate form parameter test</title>
        <link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.0/jquery.mobile-1.3.0.min.css" />
        <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
        <script src="http://code.jquery.com/mobile/1.3.0/jquery.mobile-1.3.0.min.js"></script>
    </head>
    <body>
        <div data-role="page">
            <div data-role="header">
                <form>
                    <input type="search" name="searchQuery">
                </form>
            </div>
        </div>
    </body>
</html>

If I type something in the search input, for example "foo", I will get redirected to http://path.to.my.site/search?searchQuery=foo. After that page loads, if I type something else, for example "bar", I will get redirected to http://path.to.my.site/search?searchQuery=foo&searchQuery=bar. Note the double searchQuery parameters.

If I don't use jQuery Mobile, I am simply redirected to http://path.to.my.site/search?searchQuery=bar. I don't know if this is a bug or intended behavior.

I can work around this bug by putting an action attribute on the form but I think this is still worth mentioning.

@gabrielschulhof
Collaborator

I threw the above code into a jsbin.

@gabrielschulhof
Collaborator

Simply adding action="#" on the form doesn't fix the problem.

@gabrielschulhof
Collaborator

@johnbender, @gseguin, @uGoMobi, @arschmitz, could you please have a look at the commit above? Can we get rid of the check for the method and always strip off the query?

The reason I left the check in place is that I was thinking that, if the form is submitted via POST, the URL could contain a query string, in which case those variables will be received on the server side in the GET array, whereas the data will be received in the POST array.

@gabrielschulhof gabrielschulhof referenced this issue from a commit
@gabrielschulhof gabrielschulhof Navigation: When submitting a form via GET, strip query off URL befor…
…e creating new query string. Fixes #5710.

(cherry picked from commit 0d4e839)
92b813f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.