Duplicated form parameters when form is submitted repeatedly #5710

Closed
elias6 opened this Issue Feb 28, 2013 · 3 comments

Comments

Projects
None yet
2 participants
@elias6

elias6 commented Feb 28, 2013

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

This comment has been minimized.

Show comment
Hide comment
@gabrielschulhof

gabrielschulhof Mar 5, 2013

Contributor

I threw the above code into a jsbin.

Contributor

gabrielschulhof commented Mar 5, 2013

I threw the above code into a jsbin.

@gabrielschulhof

This comment has been minimized.

Show comment
Hide comment
@gabrielschulhof

gabrielschulhof Mar 5, 2013

Contributor

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

Contributor

gabrielschulhof commented Mar 5, 2013

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

@gabrielschulhof

This comment has been minimized.

Show comment
Hide comment
@gabrielschulhof

gabrielschulhof Mar 14, 2013

Contributor

@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.

Contributor

gabrielschulhof commented Mar 14, 2013

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment