Closed Bug 568779 Opened 14 years ago Closed 14 years ago

the form action is overwritten by an element with id="action"


(Core :: Security, defect)

Not set





(Reporter: alien999999999, Unassigned)


User-Agent:       Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv: Gecko/20100416 Mandriva Linux/ (2010.0) Firefox/3.6.3
Build Identifier: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv: Gecko/20100416 Mandriva Linux/ (2010.0) Firefox/3.6.3

if you have a form, and inside it an input element of type select with id="action", firebug shows that the form action is overwritten with that object. Instead of a string value equal to the action attribute of that form, it is that select object.

when that form is submitted, it actually still uses the original action from the attribute. BUT that form attribute cannot be changed anymore. setting it will produce no errors, but it is not changed.

Reproducible: Always

Steps to Reproduce:
1. make a html file with a form like this:

<form id="form1" name="stuff" method="post" action="">
<select id="action">
<option value="whatever">some option</option>

2. firebug shows that form#form1 has it's action property set to the select object
3. using the form in this way produces no real problems, still the original action is used.
4. through javascript, try to modify the action ATTRIBUTE of form#form1 :

i did an example where i changed http => https and vice versa depending on a checkbox's value. (using jquery)

<input type="button" value="test" onclick="$("form#form1").attr('action', '');" />

5. by using firebug, i could see that the value of the action attribute of the form did NOT change. 
Actual Results:  
- form action property was a select object
- form action attribute was not changed

Expected Results:  
- form action property should not be changed due to a containing element with id="action"
- form action attribute should be changable.

see info in steps to reproduce
Thank you very much for the bug report, but this is the "right" behavior.  Named controls or controls with ids in the form are exposed as properties on the form itself, and override predefined properties of the form.  Web sites depend on this behavior, it's interoperably implemented across Gecko, Webkit (Safari, Chrome), Presto (Opera), and Trident (IE/Windows). 

In fact, (the "caller getter" part on namedItem, which means it installs a generic getter for any string property name).

You can still change the action in your example by using setAttribute("action", something) instead of setting the DOM "action" property if you need to modify it.
Closed: 14 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.