shithub: riscv

Download patch

ref: f1b873ba6e3f97be85816dba8075d4d97ae0cc2f
parent: 1c31521e2d4a0026c406a536efcb78d4660c9ebe
author: cinap_lenrek <[email protected]>
date: Mon Oct 24 16:39:15 EDT 2011

mothra: ignore form inputs without a name on submit

--- a/sys/src/cmd/mothra/forms.c
+++ b/sys/src/cmd/mothra/forms.c
@@ -549,6 +549,8 @@
 	for(f=form->fields;f;f=f->next) switch(f->type){
 	case TYPEIN:
 	case PASSWD:
+		if(f->name==0)
+			continue;
 		size+=ulen(f->name)+1+ulen(plentryval(f->p))+1;
 		break;
 	case INDEX:
@@ -558,14 +560,20 @@
 	case RADIO:
 		if(!f->state) break;
 	case HIDDEN:
+		if(f->name==0 || f->value==0)
+			continue;
 		size+=ulen(f->name)+1+ulen(f->value)+1;
 		break;
 	case SELECT:
+		if(f->name==0)
+			continue;
 		for(o=f->options;o;o=o->next)
-			if(o->selected)
+			if(o->selected && o->value)
 				size+=ulen(f->name)+1+ulen(o->value)+1;
 		break;
 	case TEXTWIN:
+		if(f->name==0)
+			continue;
 		size+=ulen(f->name)+1+plelen(f->textwin)*3+1;
 		break;
 	}
@@ -583,6 +591,8 @@
 	for(f=form->fields;f;f=f->next) switch(f->type){
 	case TYPEIN:
 	case PASSWD:
+		if(f->name==0)
+			continue;
 		if(sep) *bufp++=sep;
 		sep='&';
 		bufp=ucpy(bufp, f->name);
@@ -598,6 +608,8 @@
 	case RADIO:
 		if(!f->state) break;
 	case HIDDEN:
+		if(f->name==0 || f->value==0)
+			continue;
 		if(sep) *bufp++=sep;
 		sep='&';
 		bufp=ucpy(bufp, f->name);
@@ -605,8 +617,10 @@
 		bufp=ucpy(bufp, f->value);
 		break;
 	case SELECT:
+		if(f->name==0)
+			continue;
 		for(o=f->options;o;o=o->next)
-			if(o->selected){
+			if(o->selected && o->value){
 				if(sep) *bufp++=sep;
 				sep='&';
 				bufp=ucpy(bufp, f->name);
@@ -615,6 +629,8 @@
 			}
 		break;
 	case TEXTWIN:
+		if(f->name==0)
+			continue;
 		if(sep) *bufp++=sep;
 		sep='&';
 		bufp=ucpy(bufp, f->name);