w3m

Unnamed repository; edit this file to name it for gitweb.
git clone https://logand.com/git/w3m.git/
Log | Files | Refs | README

commit 055fcfd8a6322db257a36d7c9a3032e6da429caa
parent 9575fc812c983ac82179b7478a91e5982be1baed
Author: ukai <ukai>
Date:   Tue, 26 Nov 2002 17:05:22 +0000

[w3m-dev 03488] meta refresh in frame
* file.c (getMetaRefreshParam): added
	(HTMLtagproc1): use getMetaRefreshParam()
* frame.c (createFrameFile): check meta refresh
* proto.h (getMetaRefreshProgram): added
From: Hiroyuki Ito <hito@crl.go.jp>

Diffstat:
MChangeLog | 8++++++++
Mfile.c | 67+++++++++++++++++++++++++++++++++++++++++--------------------------
Mframe.c | 22++++++++++++++++++++--
Mproto.h | 1+
4 files changed, 70 insertions(+), 28 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -1,3 +1,11 @@ +2002-11-27 Hiroyuki Ito <hito@crl.go.jp> + + * [w3m-dev 03488] meta refresh in frame + * file.c (getMetaRefreshParam): added + (HTMLtagproc1): use getMetaRefreshParam() + * frame.c (createFrameFile): check meta refresh + * proto.h (getMetaRefreshProgram): added + 2002-11-27 Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp> * w3m 0.3.2.1 security fix diff --git a/file.c b/file.c @@ -3940,6 +3940,46 @@ ul_type(struct parsed_tag *tag, int default_type) } int +getMetaRefreshParam(char *q, Str *refresh_uri) +{ + int refresh_interval; + char *r; + Str s_tmp = NULL; + + if(q == NULL || refresh_uri == NULL) + return 0; + + refresh_interval = atoi(q); + + while (*q) { + if (!strncasecmp(q, "url=", 4)) { + q += 4; + if (*q == '\"') /* " */ + q++; + r = q; + while (*r && !IS_SPACE(*r) && *r != ';') + r++; + s_tmp = Strnew_charp_n(q, r - q); + + if (s_tmp->ptr[s_tmp->length - 1] == '\"') { /* " + */ + s_tmp->length--; + s_tmp->ptr[s_tmp->length] = '\0'; + } + q = r; + } + while (*q && *q != ';') + q++; + if (*q == ';') + q++; + while (*q && *q == ' ') + q++; + } + *refresh_uri = s_tmp; + return refresh_interval; +} + +int HTMLtagproc1(struct parsed_tag *tag, struct html_feed_environ *h_env) { char *p, *q, *r; @@ -4576,33 +4616,8 @@ HTMLtagproc1(struct parsed_tag *tag, struct html_feed_environ *h_env) else #endif if (p && q && !strcasecmp(p, "refresh")) { - int refresh_interval = atoi(q); Str s_tmp = NULL; - - while (*q) { - if (!strncasecmp(q, "url=", 4)) { - q += 4; - if (*q == '\"') /* " */ - q++; - r = q; - while (*r && !IS_SPACE(*r) && *r != ';') - r++; - s_tmp = Strnew_charp_n(q, r - q); - - if (s_tmp->ptr[s_tmp->length - 1] == '\"') { /* " - */ - s_tmp->length--; - s_tmp->ptr[s_tmp->length] = '\0'; - } - q = r; - } - while (*q && *q != ';') - q++; - if (*q == ';') - q++; - while (*q && *q == ' ') - q++; - } + int refresh_interval = getMetaRefreshParam(q, &s_tmp); if (s_tmp) { q = html_quote(s_tmp->ptr); tmp = diff --git a/frame.c b/frame.c @@ -599,6 +599,7 @@ createFrameFile(struct frameset *f, FILE * f1, Buffer *current, int level, fputs("-->", f1); goto token_end; case HTML_BASE: + /* "BASE" is prohibit tag */ if (parsedtag_get_value(tag, ATTR_HREF, &q)) { q = url_quote_conv(q, code); parseURL(q, &base, NULL); @@ -611,12 +612,29 @@ createFrameFile(struct frameset *f, FILE * f1, Buffer *current, int level, else d_target = url_quote_conv(q, code); } - /* fall thru, "BASE" is prohibit tag */ + Strshrinkfirst(tok, 1); + Strshrink(tok, 1); + fprintf(f1, "<!-- %s -->", tok->ptr); + goto token_end; + case HTML_META: + parsedtag_get_value(tag, ATTR_HTTP_EQUIV, &q); + if (q && !strcasecmp(q, "refresh")) { + parsedtag_get_value(tag, ATTR_CONTENT, &q); + if (q) { + Str s_tmp; + int refresh_interval = getMetaRefreshParam(q, &s_tmp); + if (s_tmp) { + q = html_quote(s_tmp->ptr); + fprintf(f1, "Refresh (%d sec) <a href=\"%s\">%s</a>\n", + refresh_interval, q, q); + } + } + } + /* fall thru, "META" is prohibit tag */ case HTML_HEAD: case HTML_N_HEAD: case HTML_BODY: case HTML_N_BODY: - case HTML_META: case HTML_DOCTYPE: /* prohibit_tags */ Strshrinkfirst(tok, 1); diff --git a/proto.h b/proto.h @@ -181,6 +181,7 @@ extern Str process_n_textarea(void); extern void feed_textarea(char *str); extern Str process_form(struct parsed_tag *tag); extern Str process_n_form(void); +extern int getMetaRefreshParam(char *q, Str *refresh_uri); extern int HTMLtagproc1(struct parsed_tag *tag, struct html_feed_environ *h_env); extern void HTMLlineproc2(Buffer *buf, TextLineList *tl);