Seeing gsoares@ diff reminded me I've had this diff lying in my tree
for a while.

- change the variable name from cmd= to arg= to match most other looking
glasses, giving a hint to browser autocomplete for addresses you type
regularly.

- default the form input field to the previously entered text.
lg_getenv already protects against characters which do not match
isalnum(_x) || strchr("-_.:/= ", _x)

Any OKs for one or both of these changes?


Index: bgplg.c
===================================================================
RCS file: /cvs/src/usr.bin/bgplg/bgplg.c,v
retrieving revision 1.9
diff -u -p -r1.9 bgplg.c
--- bgplg.c     2 Apr 2010 21:20:49 -0000       1.9
+++ bgplg.c     28 Mar 2012 08:11:34 -0000
@@ -244,7 +244,7 @@ lg_incl(const char *file)
 int
 main(void)
 {
-       char *query, *self, *cmd = NULL, *req;
+       char *query, *self, *cmd = NULL, *req = NULL;
        char **argv = NULL;
        char myname[MAXHOSTNAMELEN];
        int ret = 1, argc = 0, query_length = 0;
@@ -282,8 +282,10 @@ main(void)
                printf("fatal error: invalid request\n");
                goto err;
        }
-       if ((query = lg_getenv("QUERY_STRING", &query_length)) != NULL)
+       if ((query = lg_getenv("QUERY_STRING", &query_length)) != NULL) {
                cmd = lg_getarg("cmd=", query, query_length);
+               req = lg_getarg("arg=", query, query_length);
+       }
        printf(
            "<form action='%s'>\n"
            "<div class=\"command\">\n"
@@ -302,7 +304,10 @@ main(void)
                            cmds[i].name, cmds[i].name);
        }
        printf("</select>\n"
-           "<input type='text' name='req'/>\n"
+           "<input type='text' name='arg'");
+       if (req != NULL)
+               printf(" value='%s'", req);
+       printf("/>\n"
            "<input type='submit' value='submit'/>\n"
            "</div>\n"
            "</form>\n"
@@ -325,8 +330,7 @@ main(void)
                printf("unspecified command\n");
                goto err;
        }
-       if ((req = lg_getarg("req=", query, query_length)) != NULL) {
-               /* Could be NULL */
+       if (req != NULL) {
                argv = lg_arg2argv(req, &argc);
        }

Reply via email to