Commit 0ffecd03 authored by Hans-Peter Deifel's avatar Hans-Peter Deifel
Browse files

upload: Send correct form data in presence of checkboxes

tl;dr: Unchecked checkboxes usually don't send their value as
parameter when the form is submitted. The ajax request in our upload
code did just that which resulted in the value of checkboxes being
wrongly interpreted.

The default value of a checkbox is "on", even when it is off. The crux
is that with standard HTML forms, this value will only be included in
the form data if the checkbox is checked. The python end thus receives
"on" for a checked checkbox and the empty string for an unchecked
checkbox. It so happens that bool("on") == True and bool("") == False.

Our JavaScript code that sends the form data for the upload page
wrongly included the checkbox value, even if it was not checked. This
resulted in the python end always receiving "on".


fixes #106
parent 3ceabebc
......@@ -33,11 +33,7 @@
sm[i].disabled = true;
var xhr = new XMLHttpRequest();, form.action);
var data = new FormData();
for(var i=0; i < form.elements.length; i++) {
if(form.elements[i].type == 'submit') continue;
data.append(form.elements[i].name, form.elements[i].value);
var data = new FormData(form);
xhr.onloadend = function(ev) {
if(xhr.status == 200) {
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment