473,327 Members | 1,952 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

empty form actions

Say I have the following HTML:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
</head>

<body>
<form action="">
</form>
</body>

It seems to validate ok and my tests suggest that when the action
attribute is blank, that the action will be assumed to be the current
location, but is this a reasonable assumption? Is a
standards-compliant browser guaranteed to see empty action attributes
as being self-referential actions?

Sep 5 '06 #1
8 4738
yawnmoth wrote:
Say I have the following HTML:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
</head>

<body>
<form action="">
</form>
</body>

It seems to validate ok and my tests suggest that when the action
attribute is blank, that the action will be assumed to be the current
location, but is this a reasonable assumption? Is a
standards-compliant browser guaranteed to see empty action attributes
as being self-referential actions?
yawnmoth,

No guarantee at all. What the HTML Recommendation says is "User agent
behavior for a value other than an HTTP URI is undefined.".

See http://www.w3.org/TR/html401/interac...ml#adef-action

Chris Beall
Sep 5 '06 #2
yawnmoth wrote:

<form action="">
It seems to validate ok and my tests suggest that when the action
attribute is blank, that the action will be assumed to be the current
location, but is this a reasonable assumption?
I'm given to understand that the URL spec resolves that as the current
URL ... but I've seen browsers treat it as "./", so I'd avoid it.
--
David Dorward <http://blog.dorward.me.uk/ <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Sep 5 '06 #3
Chris Beall wrote:
yawnmoth wrote:
[snip]
>Is a standards-compliant browser guaranteed to see empty action
attributes as being self-referential actions?
Guaranteed? I wouldn't like to say. It certainly should though as that
is how empty URI references are defined.

<aside>
One thing I'm curious about is why IE resolves such URIs correctly for
action attributes, but not anchor href attributes. Perhaps it was one of
those things that Microsoft intentionally broke.
</>
No guarantee at all. What the HTML Recommendation says is "User agent
behavior for a value other than an HTTP URI is undefined.".
Yes, so specifying a URI that uses a ftp or mailto scheme, for example,
leads to undefined behaviour.

Relative URIs are permitted and a relative URI always uses the same
scheme. Therefore an empty URI reference (which is a relative URI) is
also permitted.

[snip]

Mike
Sep 6 '06 #4
Michael Winter wrote:
Chris Beall wrote:
>yawnmoth wrote:

[snip]
>>Is a standards-compliant browser guaranteed to see empty action
attributes as being self-referential actions?

Guaranteed? I wouldn't like to say. It certainly should though as that
is how empty URI references are defined.
Looking to refute this, I found that you're correct, which tells me,
unless I'm missing something *now*, that I and others have been giving
incorrect information here.

From RFC 2396 (http://www.ietf.org/rfc/rfc2396.txt):

4.2. Same-document References

A URI reference that does not contain a URI is a reference to the
current document. In other words, an empty URI reference within a
document is interpreted as a reference to the start of that document,
and a reference containing only a fragment identifier is a reference
to the identified fragment of that document. Traversal of such a
reference should not result in an additional retrieval action.
However, if the URI reference occurs in a context that is always
intended to result in a new request, as in the case of HTML's FORM
element, then an empty URI reference represents the base URI of the
current document and should be replaced by that URI when transformed
into a request.
>
<aside>
One thing I'm curious about is why IE resolves such URIs correctly for
action attributes, but not anchor href attributes. Perhaps it was one of
those things that Microsoft intentionally broke.
IE is definitely wrong. Firefox reloads the current page (including the
original query string!), which the spec passage above says it shouldn't do.

On form submission with the POST method, both browsers conform to the
passage above, even to the extent of including any query string from the
original request. With GET, the form data replaces, rather than being
appended to, the original query string.
Sep 6 '06 #5
Harlan Messinger wrote:
Michael Winter wrote:
>>yawnmoth wrote:
>>>Is a standards-compliant browser guaranteed to see empty action
attributes as being self-referential actions?

Guaranteed? I wouldn't like to say. It certainly should though as
that is how empty URI references are defined.

Looking to refute this, I found that you're correct ...
Always nice to know. :-)

Simple evidence can be found in the reference resolution examples (5.4
in RFC 3986, Appendix C in RFC 2396):

Within a representation with a well defined base URI of

http://a/b/c/d;p?q

a relative reference is transformed to its target URI as
follows.

....

"" = "http://a/b/c/d;p?q"
which tells me, unless I'm missing something *now*, that I and others
have been giving incorrect information here.
Really? Obviously I haven't read every post on the subject sent to this
group, but I've never noticed bad advice (and if I had, I'd have
mentioned it). Still, you've drawn attention to something that I've
overlooked in the past.
From RFC 2396 (http://www.ietf.org/rfc/rfc2396.txt):
By the way, 2396 has been obsoleted by 3986 (the latter being a
standard: STD 66).

[snip]
>One thing I'm curious about is why IE resolves such URIs correctly
for action attributes, but not anchor href attributes. Perhaps it
was one of those things that Microsoft intentionally broke.

IE is definitely wrong.
There was no doubt in my mind about that! It resolves such a URI as if
it were ".".
Firefox reloads the current page (including the original query
string!),
The original query string is to be expected as both the path /and/ the
query string identify a particular resource, so a same-document
reference must include both...
which the spec passage above says it shouldn't do.
....but I had overlooked the part about not re-retrieving the current
document. That said, the URI specifications do not seem to reference or
use RFC 2119 (requirements levels), and even if they did, it would be a
SHOULD, not MUST, requirement.

In this instance, I think there is justification for overriding any such
desire to prevent new requests as a user agent cannot know, just from
the URI alone, whether a new request is actually warranted. After all,
using the example from the RFC, even a URI "d;p?q" would be considered a
same-document reference as it resolves to the base URI. To force a
reload using only a link, one would have to add (and constantly alter)
the query string, or use client-side scripting (not that the latter
would be sensible).

If the desire is to eliminate a new request, then HTTP already provides
a feature capable of that very thing: caching.
On form submission ... With GET, the form data replaces, rather than
being appended to, the original query string.
Yes, I've found that to be annoying and, in my opinion, quite stupid.
Why force authors to include hidden form controls to pass on operational
parameters rather than just using the query string?

Mike
Sep 6 '06 #6
Michael Winter wrote:
Harlan Messinger wrote:
>Firefox reloads the current page (including the original query
string!),

The original query string is to be expected as both the path /and/ the
query string identify a particular resource, so a same-document
reference must include both...
Right, I didn't indicate that I understood this to be correct. It was
more like I was *marveling* that both browsers got that right.
>
>which the spec passage above says it shouldn't do.

...but I had overlooked the part about not re-retrieving the current
document. That said, the URI specifications do not seem to reference or
use RFC 2119 (requirements levels), and even if they did, it would be a
SHOULD, not MUST, requirement.

In this instance, I think there is justification for overriding any such
desire to prevent new requests as a user agent cannot know, just from
the URI alone, whether a new request is actually warranted. After all,
using the example from the RFC, even a URI "d;p?q" would be considered a
same-document reference as it resolves to the base URI. To force a
reload using only a link, one would have to add (and constantly alter)
the query string, or use client-side scripting (not that the latter
would be sensible).
AFAIK, all the browsers know not to reload the page when an HREF points
to an anchor on the current page, regardless of the URI form used in the
HREF (whether http://www.example.com/x#hello, /x#hello, or #hello).
>
If the desire is to eliminate a new request, then HTTP already provides
a feature capable of that very thing: caching.
>On form submission ... With GET, the form data replaces, rather than
being appended to, the original query string.

Yes, I've found that to be annoying and, in my opinion, quite stupid.
Why force authors to include hidden form controls to pass on operational
parameters rather than just using the query string?
Ah, but: if the form appears on the page in response to every submission
of the form by the user, then on the second submission the form's data
will be appended to the existing query string--which already includes
the data from the first form submission. This would likely break
whatever the page was supposed to be doing with the data.
Sep 6 '06 #7
Harlan Messinger wrote:

[snip]
AFAIK, all the browsers know not to reload the page when an HREF
points to an anchor on the current page, regardless of the URI form
used in the HREF (whether http://www.example.com/x#hello, /x#hello,
or #hello).
For fragments, certainly, but they're a special case. The URI
specification refers to all same-document references, as far as I can see.

[snip]
>>On form submission ... With GET, the form data replaces, rather
than being appended to, the original query string.

Yes, I've found that to be annoying and, in my opinion, quite
stupid. Why force authors to include hidden form controls to pass
on operational parameters rather than just using the query string?

Ah, but: if the form appears on the page in response to every
submission of the form by the user, then on the second submission the
form's data will be appended to the existing query string--which
already includes the data from the first form submission. This would
likely break whatever the page was supposed to be doing with the
data.
I don't think I made myself clear. Consider:

<form action="?stage=1" method="get">
<!-- ... -->
<input name="foo" value="bar">
<!-- ... -->

with a base URI of:

http://www.example.com/processor

When submitted, the URI will be

http://www.example.com/processor?foo=bar

not

http://www.example.com/processor?stage=1&foo=bar

I would expect the document URI to be completely replaced, but I don't
see why the query string needs to be stripped from the action attribute
value.

By comparison, making a POST request will use a request URI of:

http://www.example.com/processor?stage=1

In either case, if the form needed to be resubmitted, the action
attribute would still be the same as before, and the new form data would
be sent in addition to that pre-set value. The previously sent data
would not be involved.

Is that a better explanation? I think you thought that I meant that with
a /base/ URI of:

http://www.example.com/processor?name=value

I'd want the URI to be:

http://www.example.com/processor?name=value&foo=bar

or something like that, which isn't the case.

Mike
Sep 6 '06 #8
Michael Winter wrote:
Harlan Messinger wrote:

[snip]
>AFAIK, all the browsers know not to reload the page when an HREF
points to an anchor on the current page, regardless of the URI form
used in the HREF (whether http://www.example.com/x#hello, /x#hello,
or #hello).

For fragments, certainly, but they're a special case. The URI
specification refers to all same-document references, as far as I can see.

[snip]
>>>On form submission ... With GET, the form data replaces, rather
than being appended to, the original query string.

Yes, I've found that to be annoying and, in my opinion, quite
stupid. Why force authors to include hidden form controls to pass
on operational parameters rather than just using the query string?

Ah, but: if the form appears on the page in response to every
submission of the form by the user, then on the second submission the
form's data will be appended to the existing query string--which
already includes the data from the first form submission. This would
likely break whatever the page was supposed to be doing with the
data.

I don't think I made myself clear. Consider:

<form action="?stage=1" method="get">
<!-- ... -->
<input name="foo" value="bar">
<!-- ... -->

with a base URI of:

http://www.example.com/processor

When submitted, the URI will be

http://www.example.com/processor?foo=bar

not

http://www.example.com/processor?stage=1&foo=bar

I would expect the document URI to be completely replaced, but I don't
see why the query string needs to be stripped from the action attribute
value.

By comparison, making a POST request will use a request URI of:

http://www.example.com/processor?stage=1

In either case, if the form needed to be resubmitted, the action
attribute would still be the same as before, and the new form data would
be sent in addition to that pre-set value. The previously sent data
would not be involved.

Is that a better explanation?
Much more clear, thanks.

Sep 7 '06 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Cyrus D. | last post by:
Hi guys, What's the best way to test for an empty form value ? I am doing it like this now: $test = $_POST; if(strlen($test) < 1) // it is empty ! Maybe I can just go:
3
by: Christopher Mocock | last post by:
Hi all, Bit of a python newbie so need a little help with a CGI script I'm trying to write. I've got it working fine as long as the fields of the form are filled in correctly, however I need to...
4
by: Peter Bremer | last post by:
Hi all, I've got a form which lists all members of a club, with checkboxes to select them. The form offers functions to delete selected members, send email, etc. Now I want write some code to...
6
by: Ryan Liu | last post by:
Hi, I have a form, with some user control in it, usually hung up when I call form.Show(). I debug to there, I found in Visual Studio 2003, the call stack is empty! And CPU is not busy at...
6
by: Asle | last post by:
Hi, i am using ms access 2000. I have 3 tables called tblJob, tblPrint, tblDesign with one-to-one relationship. I haved divided into different tables since i dont want to have too many fields in...
26
by: pepper.gabriela | last post by:
Hello, a stupid question but... page_A.php is a page with a form. The user inserts text in four fields, then he clicks a submit button. The data goes to page_B.php: this page controls the data...
11
by: iReachable | last post by:
Hi! We are seeeing many users with XP experiencing empty form data issue. Browwer = Explorer 7.0, OS = Windows Vista Browser = Firefox 2.0.0, OS = Windows XP Browser = Explorer 6.0, OS =...
10
flexsingh
by: flexsingh | last post by:
Hello there, I have a form and when data is inputted it goes into the table and I can get it out pefectly fine, the problem I have is that if the promary key is empty it will not submit, but if any...
3
by: swethak | last post by:
Hi, I am getting the problem with form tag. i,e in in form action i am placing the some autoresponder page like <form name="form1" method="post"...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.