[w3m-dev 03496] parse <!-- ... --> in <script>

* etc.c (read_token): check <pre>
* file.c (HTMLlineproc0): remove comment processing
		check pre mode
		comment processing move
From: Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp>
This commit is contained in:
Fumitoshi UKAI
2002-11-27 16:39:13 +00:00
parent 09c3eb83b9
commit 7b5f6ea99c
3 changed files with 45 additions and 7 deletions
+9 -1
View File
@@ -1,3 +1,11 @@
2002-11-28 Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp>
* [w3m-dev 03496] parse <!-- ... --> in <script>
* etc.c (read_token): check <pre>
* file.c (HTMLlineproc0): remove comment processing
check pre mode
comment processing move
2002-11-28 Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp> 2002-11-28 Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp>
* [w3m-dev 03495] local CGI can't work * [w3m-dev 03495] local CGI can't work
@@ -5226,4 +5234,4 @@ a * [w3m-dev 03276] compile error on EWS4800
* release-0-2-1 * release-0-2-1
* import w3m-0.2.1 * import w3m-0.2.1
$Id: ChangeLog,v 1.568 2002/11/27 16:35:18 ukai Exp $ $Id: ChangeLog,v 1.569 2002/11/27 16:39:13 ukai Exp $
+12 -3
View File
@@ -1,4 +1,4 @@
/* $Id: etc.c,v 1.40 2002/11/24 16:02:22 ukai Exp $ */ /* $Id: etc.c,v 1.41 2002/11/27 16:39:17 ukai Exp $ */
#include "fm.h" #include "fm.h"
#include <pwd.h> #include <pwd.h>
#include "myctype.h" #include "myctype.h"
@@ -755,8 +755,10 @@ read_token(Str buf, char **instr, int *status, int pre, int append)
} }
if (prev_status == R_ST_NCMNT2 || prev_status == R_ST_NCMNT3 || if (prev_status == R_ST_NCMNT2 || prev_status == R_ST_NCMNT3 ||
prev_status == R_ST_IRRTAG || prev_status == R_ST_CMNT1) { prev_status == R_ST_IRRTAG || prev_status == R_ST_CMNT1) {
if (prev_status == R_ST_CMNT1 && !append) if (prev_status == R_ST_CMNT1 && !append && !pre)
Strclear(buf); Strclear(buf);
if (pre)
Strcat_char(buf, *p);
p++; p++;
goto proc_end; goto proc_end;
} }
@@ -779,7 +781,10 @@ read_token(Str buf, char **instr, int *status, int pre, int append)
} }
if (*status == R_ST_TAG0 && !REALLY_THE_BEGINNING_OF_A_TAG(p)) { if (*status == R_ST_TAG0 && !REALLY_THE_BEGINNING_OF_A_TAG(p)) {
/* it seems that this '<' is not a beginning of a tag */ /* it seems that this '<' is not a beginning of a tag */
/*
Strcat_charp(buf, "&lt;"); Strcat_charp(buf, "&lt;");
*/
Strcat_char(buf, '<');
*status = R_ST_NORMAL; *status = R_ST_NORMAL;
} }
else else
@@ -793,7 +798,9 @@ read_token(Str buf, char **instr, int *status, int pre, int append)
break; break;
case R_ST_CMNT: case R_ST_CMNT:
case R_ST_IRRTAG: case R_ST_IRRTAG:
if (!append) if (pre)
Strcat_char(buf, *p);
else if (!append)
Strclear(buf); Strclear(buf);
break; break;
case R_ST_CMNT1: case R_ST_CMNT1:
@@ -802,6 +809,8 @@ read_token(Str buf, char **instr, int *status, int pre, int append)
case R_ST_NCMNT2: case R_ST_NCMNT2:
case R_ST_NCMNT3: case R_ST_NCMNT3:
/* do nothing */ /* do nothing */
if (pre)
Strcat_char(buf, *p);
break; break;
} }
} }
+24 -3
View File
@@ -1,4 +1,4 @@
/* $Id: file.c,v 1.132 2002/11/26 18:03:24 ukai Exp $ */ /* $Id: file.c,v 1.133 2002/11/27 16:39:18 ukai Exp $ */
#include "fm.h" #include "fm.h"
#include <sys/types.h> #include <sys/types.h>
#include "myctype.h" #include "myctype.h"
@@ -5421,6 +5421,7 @@ HTMLlineproc0(char *str, struct html_feed_environ *h_env, int internal)
fclose(f); fclose(f);
} }
#if 0
/* comment processing */ /* comment processing */
if (obuf->status == R_ST_CMNT || obuf->status == R_ST_NCMNT3 || if (obuf->status == R_ST_CMNT || obuf->status == R_ST_NCMNT3 ||
obuf->status == R_ST_IRRTAG) { obuf->status == R_ST_IRRTAG) {
@@ -5431,6 +5432,7 @@ HTMLlineproc0(char *str, struct html_feed_environ *h_env, int internal)
if (obuf->status != R_ST_NORMAL) if (obuf->status != R_ST_NORMAL)
return; return;
} }
#endif
tokbuf = Strnew(); tokbuf = Strnew();
@@ -5444,13 +5446,25 @@ HTMLlineproc0(char *str, struct html_feed_environ *h_env, int internal)
while (*str != '\0') { while (*str != '\0') {
int is_tag = FALSE; int is_tag = FALSE;
int pre_mode = (obuf->table_level >= 0) ?
tbl_mode->pre_mode & TBLM_PLAIN :
obuf->flag & RB_PLAINMODE;
if (obuf->flag & RB_PLAIN) if (obuf->flag & RB_PLAIN)
goto read_as_plain; /* don't process tag */ goto read_as_plain; /* don't process tag */
if (ST_IS_COMMENT(obuf->status)) {
read_token(h_env->tagbuf, &str, &obuf->status, pre_mode, 1);
if (obuf->status != R_ST_NORMAL)
return;
if (pre_mode) {
is_tag = TRUE;
q = h_env->tagbuf->ptr;
goto read_as_pre_mode;
}
continue;
}
if (*str == '<' || ST_IS_TAG(obuf->status)) { if (*str == '<' || ST_IS_TAG(obuf->status)) {
int pre_mode = (obuf->table_level >= 0) ?
tbl_mode->pre_mode & TBLM_PLAIN : obuf->flag & RB_PLAINMODE;
/* /*
* Tag processing * Tag processing
*/ */
@@ -5462,12 +5476,15 @@ HTMLlineproc0(char *str, struct html_feed_environ *h_env, int internal)
if (!REALLY_THE_BEGINNING_OF_A_TAG(str)) { if (!REALLY_THE_BEGINNING_OF_A_TAG(str)) {
/* this is NOT a beginning of a tag */ /* this is NOT a beginning of a tag */
obuf->status = R_ST_NORMAL; obuf->status = R_ST_NORMAL;
if (pre_mode)
goto read_as_pre_mode;
HTMLlineproc1("&lt;", h_env); HTMLlineproc1("&lt;", h_env);
str++; str++;
continue; continue;
} }
read_token(h_env->tagbuf, &str, &obuf->status, pre_mode, 0); read_token(h_env->tagbuf, &str, &obuf->status, pre_mode, 0);
} }
#if 0
if (ST_IS_COMMENT(obuf->status)) { if (ST_IS_COMMENT(obuf->status)) {
if ((obuf->table_level >= 0) ? tbl_mode->pre_mode & TBLM_IGNORE if ((obuf->table_level >= 0) ? tbl_mode->pre_mode & TBLM_IGNORE
: obuf->flag & RB_IGNORE) : obuf->flag & RB_IGNORE)
@@ -5476,6 +5493,7 @@ HTMLlineproc0(char *str, struct html_feed_environ *h_env, int internal)
obuf->status = R_ST_NORMAL; obuf->status = R_ST_NORMAL;
return; return;
} }
#endif
if (h_env->tagbuf->length == 0) if (h_env->tagbuf->length == 0)
continue; continue;
if (obuf->status != R_ST_NORMAL) { if (obuf->status != R_ST_NORMAL) {
@@ -5501,6 +5519,7 @@ HTMLlineproc0(char *str, struct html_feed_environ *h_env, int internal)
q = h_env->tagbuf->ptr; q = h_env->tagbuf->ptr;
} }
read_as_pre_mode:
if (obuf->flag & (RB_INTXTA | RB_INSELECT | RB_IGNORE)) { if (obuf->flag & (RB_INTXTA | RB_INSELECT | RB_IGNORE)) {
cmd = HTML_UNKNOWN; cmd = HTML_UNKNOWN;
if (!is_tag) { if (!is_tag) {
@@ -5519,6 +5538,8 @@ HTMLlineproc0(char *str, struct html_feed_environ *h_env, int internal)
if (obuf->flag & RB_INTXTA) { if (obuf->flag & RB_INTXTA) {
if (cmd == HTML_N_TEXTAREA) if (cmd == HTML_N_TEXTAREA)
goto proc_normal; goto proc_normal;
if (is_tag)
continue;
feed_textarea(q); feed_textarea(q);
} }
else if (obuf->flag & RB_INSELECT) { else if (obuf->flag & RB_INSELECT) {