POST data replay in Firefox fails if data contains key "submit"

Description

If initial POST data that gets preserved contains a key called "submit", the Javascript code on postTemplate.html fails to submit the POST to replay the request. The reason is that the form will contain a:

<input type="hidden" name="submit" value="submit" />

which causes document.forms[0].submit to reference the <input> element, and no longer the submit function. Calling document.forms[0].submit() in this case generates this error:

Error: document.forms[0].submit() is not a function

A solution that works in modern browsers is this:

var frm = document.forms[0]; if (typeof(frm.submit) == "function") { frm.submit(); } else { var x = document.createElement("form"); x.submit.apply(frm); }

Doesn't work in IE6 though, in which x.submit.apply does not exist for some weird reason. For that browser I was not able to find a way to call the original submit() function, so it might be necessary to manually add an input button with appendChild and .click() it in another if (x.submit.appy) branch, or restore the noscript submit button alltogether and require the user to click it.

Environment

Red Hat Enterprise Linux Server release 5.8 (Tikanga)
Apache 2.2.23
Firefox 18.0.2 (Windows 7 SP1 x64)

is duplicated by

Activity

Show:

Scott Cantor December 2, 2013 at 5:06 PM

Closing on release.

Scott Cantor November 21, 2013 at 5:59 PM

http://svn.shibboleth.net/view/cpp-sp?rev=3878&view=rev

Pulled submit button out of noscript block, and switched to a click() by ID, as suggested in the duplicate bug.

Anything more exotic is an exercise for the deployer.

Takeshi Nishimura October 26, 2013 at 3:51 AM
Edited

so it might be necessary to manually add an input button with appendChild and .click()

Something like this?

$ diff postTemplate.html{.dist,} 9c9 < document.forms[0].submit(); --- > submit_helper(document.forms[0]); 16c16 < document.forms[0].submit(); --- > submit_helper(document.forms[0]); 18a19,28 > function submit_helper(form) { > if (typeof(form.submit) == "function") > form.submit(); > else { > var e = document.createElement("input"); > e.type = "submit"; > form.appendChild(e); > e.click(); > } > }
Fixed
Pinned fields
Click on the next to a field label to start pinning.

Details

Assignee

Reporter

Fix versions

Affects versions

Created July 8, 2013 at 9:22 AM
Updated August 4, 2021 at 9:25 PM
Resolved November 21, 2013 at 5:59 PM

Flag notifications