<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>34315</bug_id>
          
          <creation_ts>2010-01-29 01:27:07 -0800</creation_ts>
          <short_desc>Form serialization doesn&apos;t include a submit input whose onclick() handler calls form.submit()</short_desc>
          <delta_ts>2010-05-12 13:24:59 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Forms</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          <dependson>13012</dependson>
          <blocked>39021</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Josip Rodin">joy+webkit</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>ap</cc>
    
    <cc>dglazkov</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>185773</commentid>
    <comment_count>0</comment_count>
    <who name="Josip Rodin">joy+webkit</who>
    <bug_when>2010-01-29 01:27:07 -0800</bug_when>
    <thetext>Hi there.

A user reported a problem with Chrome, which I reproduced with Midori,
so I&apos;m filing this on the WebKit library that my Midori package uses.

The automatic platform detection has limited the version choices to some MacOSX set, which isn&apos;t really correct... My Midori and its WebKit library version 1.1.15.2 runs on Linux, while the user&apos;s browser identifies as &quot;Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/532.0 (KHTML, like Gecko) Chrome/3.0.195.38 Safari/532.0&quot;.

When a HTML form does this:

&lt;form method=&quot;post&quot; name=&quot;statsFRM&quot;&gt;
&lt;script type=&quot;text/javascript&quot;&gt;  
&lt;!--
function submitnormal(action) {
        document.statsFRM.action = &quot;?id=something&quot;;
        document.statsFRM.submit();
}
--&gt;
&lt;/script&gt;
&lt;input type=&quot;submit&quot; value=&quot;Good stuff&quot; name=&quot;ok&quot; onclick=&quot;submitnormal()&quot;&gt;
&lt;input type=&quot;submit&quot; value=&quot;Bad stuff&quot; name=&quot;rej&quot; onclick=&quot;submitnormal()&quot;&gt;

...the WebKit-based web browsers fail to POST an element named &quot;ok&quot; or &quot;rej&quot;
to the web server.

I could find no obvious explanation for this omission.

http://www.w3.org/TR/html401/interact/forms.html says fairly clearly:

17.13.3 Processing form data
	When the user submits a form (e.g., by activating a submit button),
	the user agent processes it as follows.
	Step one: Identify the successful controls 
	[...]

17.13.2 Successful controls

	A successful control is &quot;valid&quot; for submission. Every successful
	control has its control name paired with its current value as part
	of the submitted form data set. A successful control must be defined
	within a FORM element and must have a control name.
	[...]
	If a form contains more than one submit button, only the activated
	submit button is successful.
	[...]

Hence, the activated submit button *is* supposed to be successful as well
as submitted via POST.

There seems to be no reason for the &apos;onclick&apos; attribute to void the success
of the activated submit button, at least not per 18.2.3 &apos;Intrinsic events&apos;
which defines it.

Please fix this. TIA.

FWIW the workaround I had to use consists of passing the omitted name
as submitnormal(&apos;ok&apos;) or submitnormal(&apos;rej&apos;) in the onclick attribute,
and then constructing a new hidden input element just before submission:
        wanted_action.setAttribute(&apos;type&apos;, &apos;hidden&apos;);
        wanted_action.setAttribute(&apos;name&apos;, action);  
        wanted_action.setAttribute(&apos;value&apos;, action); 
        document.statsFRM.appendChild(wanted_action);



This is also http://bugs.debian.org/566981</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>186013</commentid>
    <comment_count>1</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2010-01-29 17:17:55 -0800</bug_when>
    <thetext>I think that this is technically a duplicate of bug 13012, but the symptom is so different that we should probably track it separately for now.

This JavaScript code is clearly fragile - it makes no sense to call &quot;document.statsFRM.submit();&quot; given that the submission is going to happen anyway (and yes, even the change to action will take effect).

Does this affect any sites in real life? That&apos;s usually the primary key to determine priority of fixing issues such as this.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>186015</commentid>
    <comment_count>2</comment_count>
      <attachid>47748</attachid>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2010-01-29 17:18:21 -0800</bug_when>
    <thetext>Created attachment 47748
test case adapted for running locally</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>186108</commentid>
    <comment_count>3</comment_count>
    <who name="Josip Rodin">joy+webkit</who>
    <bug_when>2010-01-30 03:53:24 -0800</bug_when>
    <thetext>Alexey, you&apos;re right, just losing the explicit submit() is a clean workaround, and it seems to do no harm to other browsers. Thanks. Feel free to merge.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>47748</attachid>
            <date>2010-01-29 17:18:21 -0800</date>
            <delta_ts>2010-01-29 17:18:21 -0800</delta_ts>
            <desc>test case adapted for running locally</desc>
            <filename>form.html</filename>
            <type>text/html</type>
            <size>492</size>
            <attacher name="Alexey Proskuryakov">ap</attacher>
            
              <data encoding="base64">PGJvZHk+Cjxmb3JtIG1ldGhvZD0icG9zdCIgbmFtZT0ic3RhdHNGUk0iIGFjdGlvbj0iaHR0cDov
LzEyNy4wLjAuMTo4MDAwL3htbGh0dHByZXF1ZXN0L3Jlc291cmNlcy9wb3N0LWVjaG8uY2dpIj4K
CjxzY3JpcHQgdHlwZT0idGV4dC9qYXZhc2NyaXB0Ij4gIApmdW5jdGlvbiBzdWJtaXRub3JtYWwo
YWN0aW9uKSB7CiAgICBkb2N1bWVudC5zdGF0c0ZSTS5hY3Rpb24gKz0gIj9pZD1zb21ldGhpbmci
OwogICAgZG9jdW1lbnQuc3RhdHNGUk0uc3VibWl0KCk7Cn0KPC9zY3JpcHQ+Cgo8aW5wdXQgdHlw
ZT0idGV4dCIgdmFsdWU9IlNvbWUgdGV4dCIgbmFtZT0idHh0Ij4KPGlucHV0IHR5cGU9InN1Ym1p
dCIgdmFsdWU9Ikdvb2Qgc3R1ZmYiIG5hbWU9Im9rIiBvbmNsaWNrPSJzdWJtaXRub3JtYWwoKSI+
CjxpbnB1dCB0eXBlPSJzdWJtaXQiIHZhbHVlPSJCYWQgc3R1ZmYiIG5hbWU9InJlaiIgb25jbGlj
az0ic3VibWl0bm9ybWFsKCkiPgo8L2Zvcm0+CjwvYm9keT4K
</data>

          </attachment>
      

    </bug>

</bugzilla>