https://bugs.dragonflybsd.org/https://bugs.dragonflybsd.org/favicon.ico?16293952082009-07-29T00:14:39ZDragonFlyBSD bugtrackerDragonFlyBSD - Bug #1443: Bug tracker web interface sometimes records submissions twice (with firefox)https://bugs.dragonflybsd.org/issues/1443?journal_id=69832009-07-29T00:14:39Zqhwt+dfly
<ul></ul><p>On Tue, Jul 28, 2009 at 04:56:06PM +0200, Simon 'corecode' Schubert wrote:</p>
<blockquote>
<p>Does somebody know why firefox still allows the form to be submitted twice? The page contains this code:</p>
<p><script type="text/javascript"><br />submitted = false;<br />function submit_once() {<br />if (submitted) {<br />alert("Your request is being processed.\nPlease be patient.");<br />event.returnValue = 0; // work-around for IE</p>
</blockquote>
<p>Assignment to a property of non-existent `event' raises an exception, so<br />submit_once() can't return false.</p>
<pre><code>try {<br /> event.returnValue = 0; // work-around for IE<br /> } catch (e) {}</code></pre>
<blockquote>
<p>return 0;<br />}<br />submitted = true;<br />return 1;<br />}</p>
<p>function help_window(helpurl, width, height) {<br />HelpWin = window.open('http://bugs.dragonflybsd.org/' + helpurl, 'RoundupHelpWindow', 'scrollbars=yes,resizable=yes,toolbar=no,height='+height+',width='+width);<br />}<br /></script></p>
<p>...</p>
<p><form method="POST" name="itemSynopsis" <br />onsubmit="return submit_once()" <br />enctype="multipart/form-data" action="issue1200"><br />...</p>
</blockquote> DragonFlyBSD - Bug #1443: Bug tracker web interface sometimes records submissions twice (with firefox)https://bugs.dragonflybsd.org/issues/1443?journal_id=69852009-07-29T02:50:37Zfree
<ul></ul><p>On Wed, 29 Jul 2009 02:10:27 +0900, YONETANI Tomokazu wrote:</p>
<blockquote>
<p>try {<br />event.returnValue = 0; // work-around for IE<br />} catch (e) {}</p>
<p>return 0;<br />}</p>
</blockquote>
<p>I would suggest "finally" instead of empty "catch":<br /> try {<br /> event.returnValue = 0;<br /> } finally {<br /> return 0;<br /> }</p> DragonFlyBSD - Bug #1443: Bug tracker web interface sometimes records submissions twice (with firefox)https://bugs.dragonflybsd.org/issues/1443?journal_id=69912009-07-29T04:41:42Zcorecode
<ul></ul><p>YONETANI Tomokazu wrote:</p>
<blockquote>
<p>Assignment to a property of non-existent `event' raises an exception, so<br />submit_once() can't return false.</p>
<p>try {<br />event.returnValue = 0; // work-around for IE<br />} catch (e) {}</p>
</blockquote>
<p>That doesn't work, still can submit twice. Even this code doesn't work:<br />submitted = 0;<br />function submit_once() {<br /> if (++submitted > 1) {<br /> alert("Your request is being processed.\nPlease be patient.");<br /> try {<br /> event.returnValue = 0; // work-around for IE<br /> } catch (e) {}<br /> return 0;<br /> }<br /> return 1;<br />}</p>
<p>Seems to be some race condition in javascript/firefox?</p>
<p>cheers<br /> simon</p> DragonFlyBSD - Bug #1443: Bug tracker web interface sometimes records submissions twice (with firefox)https://bugs.dragonflybsd.org/issues/1443?journal_id=69922009-07-29T05:09:46Zfree
<ul></ul><p>On Tue, 28 Jul 2009 23:36:56 +0200, Simon 'corecode' Schubert wrote:</p>
<blockquote>
<p>Seems to be some race condition in javascript/firefox?</p>
<p>cheers<br />simon</p>
</blockquote>
<p>Don't think so. Are you sure that the form that is actually being <br />submitted and the form defined as</p>
<p><form method="POST" name="itemSynopsis" <br /> onsubmit="return submit_once()" <br /> enctype="multipart/form-data" action="issue1443"></p>
<p>are the same? Try to place a debug message in the submit_once() function <br />using window.alert('debug') and see if messagebox appears. If not, then <br />the submitting form is not the one marked with onsubmit action.</p> DragonFlyBSD - Bug #1443: Bug tracker web interface sometimes records submissions twice (with firefox)https://bugs.dragonflybsd.org/issues/1443?journal_id=69932009-07-29T05:31:48Zcorecode
<ul></ul><p>free_coder (via DragonFly issue tracker) wrote:</p>
<blockquote>
<p>free_coder <<a class="email" href="mailto:free@localhost.localdomain">free@localhost.localdomain</a>> added the comment:</p>
<p>On Tue, 28 Jul 2009 23:36:56 +0200, Simon 'corecode' Schubert wrote:</p>
<blockquote>
<p>Seems to be some race condition in javascript/firefox?</p>
<p>cheers<br />simon</p>
</blockquote>
<p>Don't think so. Are you sure that the form that is actually being <br />submitted and the form defined as</p>
<p><form method="POST" name="itemSynopsis" <br />onsubmit="return submit_once()" <br />enctype="multipart/form-data" action="issue1443"></p>
<p>are the same? Try to place a debug message in the submit_once() function <br />using window.alert('debug') and see if messagebox appears. If not, then <br />the submitting form is not the one marked with onsubmit action.</p>
</blockquote>
<p>The original messagebox appears, so submit_once() is certainly being called.</p>
<p>cheers<br /> simon</p> DragonFlyBSD - Bug #1443: Bug tracker web interface sometimes records submissions twice (with firefox)https://bugs.dragonflybsd.org/issues/1443?journal_id=69942009-07-29T06:14:42Zfree
<ul></ul><p>It seems I've solved the problem, the function must return a boolean type <br />(false or true) and not just 0 or 1. That is:</p>
<p>function submit_once() {<br /> if (++submitted > 1) {<br /> alert("Your request is being processed.\nPlease be patient.");<br /> try {<br /> event.returnValue = 0; // work-around for IE<br /> } catch (e) {}<br /> return false;<br /> }<br /> return true;<br />}</p>
<p>And it would be nice if we declare the "submitted" variable with "var", <br />i.e. var submitted = 0;</p>
<p>cheers.</p> DragonFlyBSD - Bug #1443: Bug tracker web interface sometimes records submissions twice (with firefox)https://bugs.dragonflybsd.org/issues/1443?journal_id=70012009-08-06T00:43:03Zfree
<ul></ul><p>Hello,</p>
<p>I see the JS code in the site is not fixed (why?). In the previous <br />message I've proposed a solution which had been successfully tested by me.</p>
<p>Thanks.</p> DragonFlyBSD - Bug #1443: Bug tracker web interface sometimes records submissions twice (with firefox)https://bugs.dragonflybsd.org/issues/1443?journal_id=70082009-08-06T02:37:23Zcorecode
<ul></ul><p>okay, it seems that the combination of boolean return and try/catch was necessary.</p>
<p>fix implemented, thanks for the followup!</p>