[links-list] Form actions with ? in the URI

Adam Harvey matlhdam at iinet.net.au
Sun Feb 18 05:01:54 PST 2001


Hi

Attached is a (very short) patch that fixes what appears to be some
non-standard behaviour with form action URIs. It's probably best 
illustrated with an example... this code doesn't work as expected in
Links:

<FORM NAME="foo" METHOD="post" ACTION="/cgi-bin/foo.cgi?action=bar">
...
</FORM>

That form should post the data to the URI "/cgi-bin/foo.cgi?action=bar",
but strips the ? and all following characters to make the URI simply
"/cgi-bin/foo.cgi".

The patch attached retains the full action for forms that are to be
POSTed, but continues to strip the ? and trailing characters for GET
forms, since they'll have the form data sent that way and it seems a
bit brain-damaged to send a URI like
"/cgi-bin/foo.cgi?action=bar?formitem=onetwothree".

AFAIK, this brings Links into line with other browsers in this regard.

Adam
-------------- next part --------------
diff -ruN links-0.95/html.c links-0.95-new/html.c
--- links-0.95/html.c	Mon Jan  1 06:26:52 2001
+++ links-0.95-ah1/html.c	Sat Feb 17 21:39:46 2001
@@ -1040,7 +1040,6 @@
 	} else {
 		if ((ch = strchr(form->action = stracpy(format.href_base), POST_CHAR))) *ch = 0;
 	}
-	if (ch = strchr(form->action, '?')) *ch = 0;
 	if ((al = get_target(a))) {
 		form->target = al;
 	} else {
@@ -1048,7 +1047,10 @@
 	}
 	form->method = FM_GET;
 	if ((al = get_attr_val(a, "method"))) {
-		if (!strcasecmp(al, "get")) form->method = FM_GET;
+		if (!strcasecmp(al, "get")) {
+			form->method = FM_GET;
+			if (ch = strchr(form->action, '?')) *ch = 0;
+		}
 		if (!strcasecmp(al, "post")) {
 			char *ax;
 			form->method = FM_POST;


More information about the links-list mailing list