If we submit a form using GET and there is no form data we should not append a question mark '?'.
<form action="b.html" method="GET"></form>
This should navigate to "b.html" and not "b.html?"
The bug seems to be in KURL::setQuery. It always adds a '?' no matter what
Brett, KURLGoogle has a comment that it does not add the '?' and that we need to eliminate this difference but it seems we always get the extra '?' with KURLGoogle as well.
> This should navigate to "b.html" and not "b.html?"
Why should it?
See bug 8051 - the form is not quite empty in that case, but that's close enough to question what the difference affecting behavior really is.
Per a comment Erik added to bug 8051, Firefox doesn't do this (any more?). We need to test related cases thoroughly to determine if it's safe to undo this fix, and test IE, of course.
Bug 8051 was about an empty form that was not submitted because the URL didn't change. The action attribute was set to "". We do need to submit the form in that case and this is what Firefox does. However, we should not add a '?'. This is important for another case when the form is empty and the action is set to a fragment identifier (#a). This is important for fixing bug 20342.
I'm willing to fix this and 20342 if we can agree on the following Firefox's behavior.
any updates to this bug/behavior?
We use form GET for tracking purposes, and some CMS breaks on urls with question marks.
Here's a demo http://jsfiddle.net/a4TeB/
We still lack results of IE testing. WebKit and IE together make a qualified majority of Web browsers, which is why it's important even if Firefox is different.
IE9 follows Firefox's behavior, but WebKit follows the standards. (in my understanding)
The HTML5 forms TR says that method="GET" means the form data is URL-encoded, and the algorithm for that returns the empty string. The action URL mutating algorithm says the query is set to this empty string, and then the URL is serialized using the URL spec. The URL spec says that if the query is non-null, the URL gets a "?".
Query computation: http://www.w3.org/TR/html5/forms.html#application/x-www-form-urlencoded-encoding-algorithm
Action URL mutating: http://www.w3.org/TR/html5/forms.html#submit-mutate-action
URL serializing: http://url.spec.whatwg.org/#serializing
Assuming we want to follow Firefox / IE instead of the standard, fixing this bug should be a matter of reverting the KURL change and updating the layout test in https://bugs.webkit.org/show_bug.cgi?id=8051
Please let me know. I'd be happy to submit a patch.
All other major browsers work correctly and do NOT append question mark to URL in case of empty GET-method form, namely:
* Firefox (at least version 4+),
* Opera 12 (Opera before switching to Chromium),
* Internet Explorer (at least version 8+),
* Microsoft Edge (Windows 10's brand new browser).
That's just common sense since the `?` separator is unneeded if there is nothing to separate (query string is empty).
Forms without fields are a valid way for creating buttons that effectively act as links that always point to the same exact URL .
WebKit and its fork named Chromium are currently the only engines that need the workaround based on server-side redirection .