Bug 17042 - <form> tags used without action attribute but with a <base> tag
Summary: <form> tags used without action attribute but with a <base> tag
Alias: None
Product: WebKit
Classification: Unclassified
Component: Forms (show other bugs)
Version: 523.x (Safari 3)
Hardware: Mac OS X 10.5
: P2 Normal
Assignee: Nobody
Depends on:
Reported: 2008-01-27 23:06 PST by Robert Sesek
Modified: 2008-02-06 14:29 PST (History)
1 user (show)

See Also:

Testcase (330 bytes, text/html)
2008-01-27 23:07 PST, Robert Sesek
no flags Details
Patch using FF and IE implementation (1.14 KB, patch)
2008-01-28 12:23 PST, Robert Sesek
darin: review-
Details | Formatted Diff | Diff
Patch, take 2 (3.35 KB, patch)
2008-01-30 21:44 PST, Robert Sesek
darin: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Robert Sesek 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.


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
Comment 1 Robert Sesek 2008-01-27 23:07:41 PST
Created attachment 18734 [details]
Comment 2 Alexey Proskuryakov 2008-01-28 09:56:14 PST
Both Firefox 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.
Comment 3 Robert Sesek 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):


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.
Comment 4 Robert Sesek 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.
Comment 5 Darin Adler 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.
Comment 6 Robert Sesek 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.
Comment 7 Darin Adler 2008-01-31 10:47:06 PST
Comment on attachment 18808 [details]
Patch, take 2

Comment 8 Mark Rowe (bdash) 2008-02-04 21:34:46 PST
Landed in r29989.  Thanks for the patch!