Bug 18970

Summary: Numerically named input fields cause document.forms loop problems
Product: WebKit Reporter: Dave Kiger <dkiger>
Component: WebCore JavaScriptAssignee: Alexey Proskuryakov <ap>
Status: RESOLVED FIXED    
Severity: Normal CC: ap, sam
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Mac   
OS: OS X 10.5   
Attachments:
Description Flags
Example page which demonstrates bug
none
proposed fix darin: review+

Dave Kiger
Reported 2008-05-09 08:54:35 PDT
Javascript: <script type="text/javascript"> function showMe() { var varString = ''; var element = ''; var oneForm = document.forms["test_form"]; var totalElements = oneForm.length; for (var increment = 0; increment < totalElements; increment++) { element = oneForm[increment]; if (element.tagName == "INPUT" || element.tagName == "TEXTAREA") { if ( (element.type == 'checkbox' && element.checked) || (element.type == 'radio' && element.checked) || element.type == 'text' || element.type == 'password' || element.type == 'hidden' ) { varString += element.name + "=" + element.value + "\n&"; } } else if (element.tagName == "SELECT") { varString += element.name + "=" + element.options[element.selectedIndex].value + "\n&"; } } varString += "is_ajax=yes"; document.getElementById('results').value = varString; } </script> HTML: <form action="testme.html" method="post" name="test_form" id="test_form"> <input type="hidden" name="field_000" value="value_000"> <input type="hidden" name="field_001" value="value_001"> <input type="hidden" name="field_002" value="value_002"> <input type="hidden" name="field_003" value="value_003"> <input type="hidden" name="field_004" value="value_004"> <input type="hidden" name="field_005" value="value_005"> <input type="hidden" name="field_006" value="value_006"> <input type="hidden" name="field_007" value="value_007"> <input type="hidden" name="field_008" value="value_008"> <input type="hidden" name="field_009" value="value_009"> <input type="hidden" name="field_009" value="value_009"> <input type="hidden" name="field_010" value="value_010"> <input type="hidden" name="field_011" value="value_011"> <input type="hidden" name="field_012" value="value_012"> <input type="hidden" name="field_013" value="value_013"> <input type="hidden" name="field_014" value="value_014"> <input type="hidden" name="field_015" value="value_015"> <input type="hidden" name="field_016" value="value_016"> <input type="hidden" name="field_017" value="value_017"> <input type="hidden" name="field_018" value="value_018"> <input type="hidden" name="field_019" value="value_019"> <input type="hidden" name="field_020" value="value_020"> <input type="hidden" name="field_021" value="value_021"> <input type="hidden" name="field_022" value="value_022"> <input type="hidden" name="field_023" value="value_023"> <input type="hidden" name="field_024" value="value_024"> <input type="hidden" name="field_025" value="value_025"> <input type="hidden" name="field_026" value="value_026"> <input type="hidden" name="field_027" value="value_027"> <input type="hidden" name="field_028" value="value_028"> <input type="hidden" name="field_029" value="value_029"> <input type="hidden" name="field_030" value="value_030"> <input type="hidden" name="field_031" value="value_031"> <input type="hidden" name="field_032" value="value_032"> <input type="hidden" name="field_033" value="value_033"> <input type="hidden" name="field_034" value="value_034"> <input type="hidden" name="field_035" value="value_035"> <input type="hidden" name="field_036" value="value_036"> <input type="hidden" name="field_037" value="value_037"> <input type="hidden" name="field_038" value="value_038"> <input type="hidden" name="field_039" value="value_039"> <input type="hidden" name="field_040" value="value_040"> <input type="hidden" name="field_041" value="value_041"> <input type="hidden" name="field_042" value="value_042"> <input type="hidden" name="field_043" value="value_043"> <input type="hidden" name="field_044" value="value_044"> <input type="hidden" name="0" value="0"> <input type="hidden" name="1" value="0"> <input type="hidden" name="2" value="2"> <input type="hidden" name="3" value="0"> <input type="hidden" name="4" value="0"> <input type="hidden" name="5" value="0"> <input type="hidden" name="6" value="0"> <input type="hidden" name="7" value="0"> <input type="hidden" name="8" value="0"> <input type="hidden" name="9" value="0"> <input type="hidden" name="10" value="0"> <input type="hidden" name="11" value="0"> <input type="hidden" name="field_045" value="value_045"> <input type="hidden" name="field_046" value="value_046"> <input type="hidden" name="field_047" value="value_047"> <input type="hidden" name="field_048" value="value_048"> <input type="hidden" name="field_049" value="value_049"> <input type="hidden" name="field_050" value="value_050"> <input type="hidden" name="field_051" value="value_051"> <input type="hidden" name="field_052" value="value_052"> <input type="hidden" name="field_053" value="value_053"> <input type="hidden" name="field_054" value="value_054"> <input type="hidden" name="field_055" value="value_055"> <input type="hidden" name="field_056" value="value_056"> <input type="hidden" name="field_057" value="value_057"> <input type="hidden" name="field_058" value="value_058"> <input type="hidden" name="field_059" value="value_059"> <input type="hidden" name="field_060" value="value_060"> <input type="hidden" name="field_061" value="value_061"> <input type="hidden" name="field_062" value="value_062"> <input type="hidden" name="field_063" value="value_063"> <input type="hidden" name="field_064" value="value_064"> <input type="hidden" name="field_065" value="value_065"> <input type="hidden" name="field_066" value="value_066"> <input type="hidden" name="field_067" value="value_067"> <input type="hidden" name="field_068" value="value_068"> <input type="hidden" name="field_069" value="value_069"> <input type="hidden" name="field_070" value="value_070"> <textarea cols="50" rows="30" name="results" id="results"></textarea><br><br> <button type="button" onClick="showMe();">Test Me!</button> </form> Expected Results: field_000=value_000 &field_001=value_001 &field_002=value_002 &field_003=value_003 &field_004=value_004 &field_005=value_005 &field_006=value_006 &field_007=value_007 &field_008=value_008 &field_009=value_009 &field_009=value_009 &field_010=value_010 &field_011=value_011 &field_012=value_012 &field_013=value_013 &field_014=value_014 &field_015=value_015 &field_016=value_016 &field_017=value_017 &field_018=value_018 &field_019=value_019 &field_020=value_020 &field_021=value_021 &field_022=value_022 &field_023=value_023 &field_024=value_024 &field_025=value_025 &field_026=value_026 &field_027=value_027 &field_028=value_028 &field_029=value_029 &field_030=value_030 &field_031=value_031 &field_032=value_032 &field_033=value_033 &field_034=value_034 &field_035=value_035 &field_036=value_036 &field_037=value_037 &field_038=value_038 &field_039=value_039 &field_040=value_040 &field_041=value_041 &field_042=value_042 &field_043=value_043 &field_044=value_044 &0=0 &1=0 &2=2 &3=0 &4=0 &5=0 &6=0 &7=0 &8=0 &9=0 &10=0 &11=0 &field_045=value_045 &field_046=value_046 &field_047=value_047 &field_048=value_048 &field_049=value_049 &field_050=value_050 &field_051=value_051 &field_052=value_052 &field_053=value_053 &field_054=value_054 &field_055=value_055 &field_056=value_056 &field_057=value_057 &field_058=value_058 &field_059=value_059 &field_060=value_060 &field_061=value_061 &field_062=value_062 &field_063=value_063 &field_064=value_064 &field_065=value_065 &field_066=value_066 &field_067=value_067 &field_068=value_068 &field_069=value_069 &field_070=value_070 &is_ajax=yes Actual Results: 0=0 &1=0 &2=2 &3=0 &4=0 &5=0 &6=0 &7=0 &8=0 &9=0 &10=0 &11=0 &field_011=value_011 &field_012=value_012 &field_013=value_013 &field_014=value_014 &field_015=value_015 &field_016=value_016 &field_017=value_017 &field_018=value_018 &field_019=value_019 &field_020=value_020 &field_021=value_021 &field_022=value_022 &field_023=value_023 &field_024=value_024 &field_025=value_025 &field_026=value_026 &field_027=value_027 &field_028=value_028 &field_029=value_029 &field_030=value_030 &field_031=value_031 &field_032=value_032 &field_033=value_033 &field_034=value_034 &field_035=value_035 &field_036=value_036 &field_037=value_037 &field_038=value_038 &field_039=value_039 &field_040=value_040 &field_041=value_041 &field_042=value_042 &field_043=value_043 &field_044=value_044 &0=0 &1=0 &2=2 &3=0 &4=0 &5=0 &6=0 &7=0 &8=0 &9=0 &10=0 &11=0 &field_045=value_045 &field_046=value_046 &field_047=value_047 &field_048=value_048 &field_049=value_049 &field_050=value_050 &field_051=value_051 &field_052=value_052 &field_053=value_053 &field_054=value_054 &field_055=value_055 &field_056=value_056 &field_057=value_057 &field_058=value_058 &field_059=value_059 &field_060=value_060 &field_061=value_061 &field_062=value_062 &field_063=value_063 &field_064=value_064 &field_065=value_065 &field_066=value_066 &field_067=value_067 &field_068=value_068 &field_069=value_069 &field_070=value_070 &is_ajax=yes
Attachments
Example page which demonstrates bug (7.02 KB, text/html)
2008-05-09 08:56 PDT, Dave Kiger
no flags
proposed fix (8.07 KB, patch)
2009-02-17 07:21 PST, Alexey Proskuryakov
darin: review+
Dave Kiger
Comment 1 2008-05-09 08:56:24 PDT
Created attachment 21039 [details] Example page which demonstrates bug
Alexey Proskuryakov
Comment 2 2009-02-17 07:21:15 PST
Created attachment 27729 [details] proposed fix
Darin Adler
Comment 3 2009-02-22 22:33:37 PST
Comment on attachment 27729 [details] proposed fix r=me
Alexey Proskuryakov
Comment 4 2009-02-23 00:53:32 PST
Committed revision 41131.
Note You need to log in before you can comment on or make changes to this bug.