Bug 17042

Summary: <form> tags used without action attribute but with a <base> tag
Product: WebKit Reporter: Robert Sesek <rsesek>
Component: FormsAssignee: Nobody <webkit-unassigned>
Status: VERIFIED FIXED    
Severity: Normal CC: ap
Priority: P2    
Version: 523.x (Safari 3)   
Hardware: Mac   
OS: OS X 10.5   
Attachments:
Description Flags
Testcase
none
Patch using FF and IE implementation
darin: review-
Patch, take 2 darin: review+

Robert Sesek
Reported 2008-01-27 23:06:47 PST
When a HTML document has <base> tag, all relative URIs should be resolved in regards to that (as per the W3 spec on the matter: http://www.w3.org/TR/html401/struct/links.html#h-12.4). However, the handling of <form> elements without an "action" attribute is incorrect (when using Firefox and the HTML spec as references). If you were to use a <form> tag without an action attribute alongside a <base> tag, then the form will submit to *only* to the href of the <base> tag. Normally, when a <form> tag does not have an action attribute and a <base> tag is not present, the form submits to the originating page. Thus, the logical behavior should be as follows: when a <form> tag does not have an action attribute and a <base> tag is present, then the form should submit to the href of the <base> tag concatenated by the originating page. Example: Base Tag: http://example.com/base/ Originating page: foo.php Current implementation would submit to: http://example.com/base/ Fixing this bug would result in submitting to: http://example.com/base/foo.php
Attachments
Testcase (330 bytes, text/html)
2008-01-27 23:07 PST, Robert Sesek
no flags
Patch using FF and IE implementation (1.14 KB, patch)
2008-01-28 12:23 PST, Robert Sesek
darin: review-
Patch, take 2 (3.35 KB, patch)
2008-01-30 21:44 PST, Robert Sesek
darin: review+
Robert Sesek
Comment 1 2008-01-27 23:07:41 PST
Created attachment 18734 [details] Testcase
Alexey Proskuryakov
Comment 2 2008-01-28 09:56:14 PST
Both Firefox 2.0.0.9 and IE7 seem to ignore base URI when submitting this form (and submit to <http://bugs.webkit.org/attachment.cgi?submit=Submit+The+Form>). Are you seeing different results? Does this issue affect any actual sites? This would make it more important, of course. Confirming as a difference with IE and Firefox, but I'm not sure what behavior would be best.
Robert Sesek
Comment 3 2008-01-28 11:42:03 PST
The only site that I've experienced this issue on is the internal website we use at my job, so the criticality of it is very low (as far as I can tell). As for the behavior, logically I think it makes the most sense to submit to (from the attachment): http://localhost/foo/zoo/base/attachment.cgi?submit=Submit+The+Form The reasoning: you take the <base> because all relative URIs should be resolved from that. Then concatenate the originating page's basename (in this case attachment.cgi) because when <form>s do not have an action attribute, it submits to the originating page. However, this would probably break away from the implementation of IE and FF, so perhaps just submitting to the full URL of the originating page is the best way to do it.
Robert Sesek
Comment 4 2008-01-28 12:23:26 PST
Created attachment 18741 [details] Patch using FF and IE implementation Here's a patch that would implement the Firefox and IE behavior.
Darin Adler
Comment 5 2008-01-30 12:46:25 PST
Comment on attachment 18741 [details] Patch using FF and IE implementation Thanks for contributing this fix! The code change looks OK to me, but we need a regression test. That's the policy for the WebKit project -- we require a test for any bug we fix. The LayoutTests/fast/forms directory has lots of form tests. You can probably start with one of those to make a test. For example, empty-get.html.
Robert Sesek
Comment 6 2008-01-30 21:44:22 PST
Created attachment 18808 [details] Patch, take 2 Sorry about not submitting the test, I'm not familiar with the procedure. I have updated the patch to include a layout test for this bug.
Darin Adler
Comment 7 2008-01-31 10:47:06 PST
Comment on attachment 18808 [details] Patch, take 2 r=me
Mark Rowe (bdash)
Comment 8 2008-02-04 21:34:46 PST
Landed in r29989. Thanks for the patch!
Note You need to log in before you can comment on or make changes to this bug.