diff options
Diffstat (limited to '')
-rw-r--r-- | ChangeLog | 27 | ||||
-rw-r--r-- | config.h.dist | 1 | ||||
-rwxr-xr-x | configure | 3 | ||||
-rw-r--r-- | etc.c | 11 | ||||
-rw-r--r-- | file.c | 3 | ||||
-rw-r--r-- | fm.h | 4 | ||||
-rw-r--r-- | form.c | 192 | ||||
-rw-r--r-- | frame.c | 3 | ||||
-rw-r--r-- | main.c | 9 | ||||
-rw-r--r-- | proto.h | 5 | ||||
-rw-r--r-- | rc.c | 3 |
11 files changed, 247 insertions, 14 deletions
@@ -1,5 +1,30 @@ 2002-11-06 Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp> + * [w3m-dev 03373] setting form on loading + * config.h.dist (PRE_FORM_FILE): added + * configure (PRE_FORM_FILE): added + * etc.c (openPasswdFile): define by openSecretFile() + (openSecretFile): renamed, not static + * file.c (loadGeneralFile): preFOrmUpdateBuffer() + * fm.h (Buffer): add submit + (pre_form_file): added + * form.c (struct pre_form_item): added + (struct pre_form): added + (next_token): added + (PreForm): added + (add_pre_form): added + (add_pre_form_item): added + (loadPreForm): added + (preFormUpdateBuffer): added + * frame.c (renderFrame): add preFormUpdateBuffer() + * main.c (MAIN): buf->submit check + * proto.h (preFormUpdateBuffer): added + (openSecretFile): added + (loadPreForm): added + * rc.c (sync_with_option): add loadPreForm() + +2002-11-06 Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp> + * [w3m-dev 03371] segmentation fault by large complex table. * table.c (bsearch_2short): indexarry char to short (bsearch_double): ditto @@ -4117,4 +4142,4 @@ a * [w3m-dev 03276] compile error on EWS4800 * release-0-2-1 * import w3m-0.2.1 -$Id: ChangeLog,v 1.469 2002/11/05 15:45:52 ukai Exp $ +$Id: ChangeLog,v 1.470 2002/11/05 15:56:11 ukai Exp $ diff --git a/config.h.dist b/config.h.dist index ea4947f..5b5241e 100644 --- a/config.h.dist +++ b/config.h.dist @@ -167,6 +167,7 @@ MODEL=Linux.i686-monster-ja #define HISTORY_FILE "history" #define PASSWD_FILE RC_DIR "/passwd" +#define PRE_FORM_FILE RC_DIR "/pre_form" #define USER_MAILCAP RC_DIR "/mailcap" #define SYS_MAILCAP "/etc/mailcap" #define USER_MIMETYPES "~/.mime.types" @@ -1,5 +1,5 @@ #!/bin/sh -# $Id: configure,v 1.81 2002/10/28 17:09:20 ukai Exp $ +# $Id: configure,v 1.82 2002/11/05 15:56:12 ukai Exp $ # Configuration. # @@ -2389,6 +2389,7 @@ $def_use_xface #define HISTORY_FILE "history" #define PASSWD_FILE RC_DIR "/passwd" +#define PRE_FORM_FILE RC_DIR "/pre_form" #define USER_MAILCAP RC_DIR "/mailcap" #define SYS_MAILCAP "/etc/mailcap" #define USER_MIMETYPES "~/.mime.types" @@ -1,4 +1,4 @@ -/* $Id: etc.c,v 1.28 2002/10/30 17:21:40 ukai Exp $ */ +/* $Id: etc.c,v 1.29 2002/11/05 15:56:12 ukai Exp $ */ #include "fm.h" #include <pwd.h> #include "myctype.h" @@ -1034,9 +1034,10 @@ parsePasswd(FILE * fp, int netrc) } #define PASS_IS_READABLE_MSG "SECURITY NOTE: passwd file must not be accessible by others" +#define openPasswdFile(fname) openSecretFile(fname, PASS_IS_READABLE_MSG) -static FILE * -openPasswdFile(char *fname) +FILE * +openSecretFile(char *fname, char *error_msg) { struct stat st; if (fname == NULL) @@ -1049,11 +1050,11 @@ openPasswdFile(char *fname) */ if ((st.st_mode & (S_IRWXG | S_IRWXO)) != 0) { if (fmInitialized) { - message(PASS_IS_READABLE_MSG, 0, 0); + message(error_msg, 0, 0); refresh(); } else { - fputs(PASS_IS_READABLE_MSG, stderr); + fputs(error_msg, stderr); fputc('\n', stderr); } sleep(2); @@ -1,4 +1,4 @@ -/* $Id: file.c,v 1.109 2002/10/30 17:04:02 ukai Exp $ */ +/* $Id: file.c,v 1.110 2002/11/05 15:56:13 ukai Exp $ */ #include "fm.h" #include <sys/types.h> #include "myctype.h" @@ -2022,6 +2022,7 @@ loadGeneralFile(char *path, ParsedURL *volatile current, char *referer, if (fmInitialized) term_raw(); signal(SIGINT, prevtrap); + preFormUpdateBuffer(b); return b; } @@ -1,4 +1,4 @@ -/* $Id: fm.h,v 1.67 2002/10/30 15:46:29 ukai Exp $ */ +/* $Id: fm.h,v 1.68 2002/11/05 15:56:13 ukai Exp $ */ /* * w3m: WWW wo Miru utility * @@ -438,6 +438,7 @@ typedef struct _Buffer { #endif char image_flag; char need_reshape; + Anchor *submit; } Buffer; @@ -842,6 +843,7 @@ global char *ExtBrowser2 init(NULL); global char *ExtBrowser3 init(NULL); global int BackgroundExtViewer init(TRUE); global char *passwd_file init(PASSWD_FILE); +global char *pre_form_file init(PRE_FORM_FILE); global char *ftppasswd init(NULL); #ifdef FTPPASS_HOSTNAMEGEN global int ftppass_hostnamegen init(TRUE); @@ -1,4 +1,4 @@ -/* $Id: form.c,v 1.14 2002/06/17 17:51:39 ukai Exp $ */ +/* $Id: form.c,v 1.15 2002/11/05 15:56:13 ukai Exp $ */ /* * HTML forms */ @@ -655,3 +655,193 @@ form_write_from_file(FILE * f, char *boundary, char *name, char *filename, write_end: fprintf(f, "\r\n"); } + +struct pre_form_item { + int type; + char *name; + char *value; + int checked; + struct pre_form_item *next; +}; + +struct pre_form { + ParsedURL url; + char *action; + struct pre_form_item *item; + struct pre_form *next; +}; + +static Str next_token(Str arg); +static struct pre_form *PreForm = NULL; + +static struct pre_form * +add_pre_form(struct pre_form *prev, char *url, char *action) +{ + struct pre_form *new; + + if (prev) + new = prev->next = New(struct pre_form); + else + new = PreForm = New(struct pre_form); + parseURL2(url, &new->url, NULL); + if (action && *action) + new->action = action; + else + new->action = NULL; + new->item = NULL; + new->next = NULL; + return new; +} + +static struct pre_form_item * +add_pre_form_item(struct pre_form *pf, struct pre_form_item *prev, int type, + char *name, char *value, char *checked) +{ + struct pre_form_item *new; + + if (!pf) + return NULL; + if (prev) + new = prev->next = New(struct pre_form_item); + else + new = pf->item = New(struct pre_form_item); + new->type = type; + new->name = name; + new->value = value; + if (checked && *checked && (!strcmp(checked, "0") || + strcasecmp(checked, "off") || !strcasecmp(checked, "no"))) + new->checked = 0; + else + new->checked = 1; + new->next = NULL; + return new; +} + +/* +url <url> [<action>] +text <name> <value> +file <name> <value> +passwd <name> <value> +checkbox <name> <value> [<checked>] +radio <name> <value> +submit [<name>] +*/ + +#define FILE_IS_READABLE_MSG "SECURITY NOTE: file %s must not be accessible by others" + +void +loadPreForm(void) +{ + FILE *fp; + Str line = NULL; + struct pre_form *pf = NULL; + struct pre_form_item *pi = NULL; + + fp = openSecretFile(pre_form_file, Sprintf(FILE_IS_READABLE_MSG, + pre_form_file)->ptr); + if (fp == NULL) { + PreForm = NULL; + return; + } + while (1) { + int type = 0; + char *p, *s, *arg; + + line = Strfgets(fp); + if (line->length == 0) + break; + Strchop(line); + Strremovefirstspaces(line); + p = line->ptr; + if (*p == '#' || *p == '\0') + continue; /* comment or empty line */ + s = getWord(&p); + arg = getWord(&p); + + if (!strcmp(s, "url")) { + if (!arg || !*arg) + continue; + p = getQWord(&p); + pf = add_pre_form(pf, arg, p); + pi = pf->item; + continue; + } + if (!pf) + continue; + if (!strcmp(s, "text")) + type = FORM_INPUT_TEXT; + else if (!strcmp(s, "file")) + type = FORM_INPUT_FILE; + else if (!strcmp(s, "passwd") || !strcmp(s, "password")) + type = FORM_INPUT_PASSWORD; + else if (!strcmp(s, "checkbox")) + type = FORM_INPUT_CHECKBOX; + else if (!strcmp(s, "radio")) + type = FORM_INPUT_RADIO; + else if (!strcmp(s, "submit")) + type = FORM_INPUT_SUBMIT; + else + continue; + s = getQWord(&p); + pi = add_pre_form_item(pf, pi, type, arg, s, getQWord(&p)); + } + fclose(fp); +} + +void +preFormUpdateBuffer(Buffer *buf) +{ + struct pre_form *pf; + struct pre_form_item *pi; + int i; + Anchor *a; + FormList *fl; + FormItemList *fi; + + if (!buf || !buf->formitem || !PreForm) + return; + + for (pf = PreForm; pf; pf = pf->next) { + if (Strcmp(parsedURL2Str(&buf->currentURL), parsedURL2Str(&pf->url))) + continue; + for (i = 0; i < buf->formitem->nanchor; i++) { + a = &buf->formitem->anchors[i]; + fi = (FormItemList *)a->url; + fl = fi->parent; + if (pf->action && (!fl->action || Strcmp_charp(fl->action, pf->action))) + continue; + for (pi = pf->item; pi; pi = pi->next) { + if (pi->type != fi->type) + continue; + if (pi->type == FORM_INPUT_SUBMIT) { + if (!pi->name || !*pi->name || + (fi->name && !Strcmp_charp(fi->name, pi->name))) + buf->submit = a; + continue; + } + if (!pi->name || !fi->name || Strcmp_charp(fi->name, pi->name)) + continue; + switch (pi->type) { + case FORM_INPUT_TEXT: + case FORM_INPUT_FILE: + case FORM_INPUT_PASSWORD: + fi->value = Strnew_charp(pi->value); + formUpdateBuffer(a, buf, fi); + break; + case FORM_INPUT_CHECKBOX: + if (pi->value && fi->value && + !Strcmp_charp(fi->value, pi->value)) { + fi->checked = pi->checked; + formUpdateBuffer(a, buf, fi); + } + break; + case FORM_INPUT_RADIO: + if (pi->value && fi->value && + !Strcmp_charp(fi->value, pi->value)) + formRecheckRadio(a, buf, fi); + break; + } + } + } + } +} @@ -1,4 +1,4 @@ -/* $Id: frame.c,v 1.16 2002/06/17 15:50:45 inu Exp $ */ +/* $Id: frame.c,v 1.17 2002/11/05 15:56:13 ukai Exp $ */ #include "fm.h" #include "parsetagx.h" #include "myctype.h" @@ -790,6 +790,7 @@ renderFrame(Buffer *Cbuf, int force_reload) buf->document_code = Cbuf->document_code; #endif copyParsedURL(&buf->currentURL, &Cbuf->currentURL); + preFormUpdateBuffer(buf); return buf; } @@ -1,4 +1,4 @@ -/* $Id: main.c,v 1.116 2002/10/30 17:03:27 ukai Exp $ */ +/* $Id: main.c,v 1.117 2002/11/05 15:56:13 ukai Exp $ */ #define MAINPROGRAM #include "fm.h" #include <signal.h> @@ -949,6 +949,13 @@ MAIN(int argc, char **argv, char **envp) } onA(); for (;;) { + if (Currentbuf->submit) { + Anchor *a = Currentbuf->submit; + Currentbuf->submit = NULL; + gotoLine(Currentbuf, a->start.line); + Currentbuf->pos = a->start.pos; + _followForm(TRUE); + } /* event processing */ if (n_event_queue > 0) { for (i = 0; i < n_event_queue; i++) { @@ -1,4 +1,4 @@ -/* $Id: proto.h,v 1.48 2002/10/30 15:39:41 ukai Exp $ */ +/* $Id: proto.h,v 1.49 2002/11/05 15:56:14 ukai Exp $ */ /* * This file was automatically generated by version 1.7 of cextract. * Manual editing not recommended. @@ -331,6 +331,7 @@ extern int formtype(char *typestr); extern void formRecheckRadio(Anchor *a, Buffer *buf, FormItemList *form); extern void formResetBuffer(Buffer *buf, AnchorList *formitem); extern void formUpdateBuffer(Anchor *a, Buffer *buf, FormItemList *form); +extern void preFormUpdateBuffer(Buffer *buf); extern Str textfieldrep(Str s, int width); extern void input_textarea(FormItemList *fi); extern void do_internal(char *action, char *data); @@ -520,7 +521,9 @@ extern Buffer *dirBuffer(char *dirname); extern void set_environ(char *var, char *value); extern FILE *localcgi_post(char *, char *, FormList *, char *); extern FILE *localcgi_get(char *, char *, char *); +extern FILE *openSecretFile(char *fname, char *error_msg); extern void loadPasswd(void); +extern void loadPreForm(void); extern int find_auth_user_passwd(ParsedURL *pu, char *realm, Str *uname, Str *pwd, int is_proxy); extern Str find_auth_cookie(char *host, int port, char *file, char *realm); @@ -1,4 +1,4 @@ -/* $Id: rc.c,v 1.54 2002/10/28 17:09:29 ukai Exp $ */ +/* $Id: rc.c,v 1.55 2002/11/05 15:56:14 ukai Exp $ */ /* * Initialization file etc. */ @@ -1240,6 +1240,7 @@ sync_with_option(void) displayImage = FALSE; /* XXX */ #endif loadPasswd(); + loadPreForm(); if (AcceptLang == NULL || *AcceptLang == '\0') { #if LANG == JA |