2 * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2016 Hiroyuki Yamamoto and the Claws Mail team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
28 #define SC_HTMLBUFSIZE 8192
29 #define HR_STR "────────────────────────────────────────────────"
32 typedef struct _SC_HTMLSymbol SC_HTMLSymbol
;
40 static SC_HTMLSymbol symbol_list
[] = {
52 {"™", "\342\204\242"},
54 {"¡", "\302\241"},
55 {"¢", "\302\242"},
56 {"£", "\302\243"},
57 {"¤", "\302\244"},
58 {"¥", "\302\245"},
59 {"¦", "\302\246"},
60 {"§", "\302\247"},
61 {"¨", "\302\250"},
62 {"©", "\302\251"},
63 {"ª", "\302\252"},
64 {"«", "\302\253"},
65 {"¬", "\302\254"},
66 {"­", "\302\255"},
67 {"®", "\302\256"},
68 {"¯", "\302\257"},
69 {"°", "\302\260"},
70 {"±", "\302\261"},
71 {"²", "\302\262"},
72 {"³", "\302\263"},
73 {"´", "\302\264"},
74 {"µ", "\302\265"},
75 {"¶", "\302\266"},
76 {"·", "\302\267"},
77 {"¸", "\302\270"},
78 {"¹", "\302\271"},
79 {"º", "\302\272"},
80 {"»", "\302\273"},
81 {"¼", "\302\274"},
82 {"½", "\302\275"},
83 {"¾", "\302\276"},
84 {"¿", "\302\277"},
85 {"À", "\303\200"},
86 {"Á", "\303\201"},
87 {"Â", "\303\202"},
88 {"Ã", "\303\203"},
89 {"Ä", "\303\204"},
90 {"Å", "\303\205"},
91 {"Æ", "\303\206"},
92 {"Ç", "\303\207"},
93 {"È", "\303\210"},
94 {"É", "\303\211"},
95 {"Ê", "\303\212"},
96 {"Ë", "\303\213"},
97 {"Ì", "\303\214"},
98 {"Í", "\303\215"},
99 {"Î", "\303\216"},
100 {"Ï", "\303\217"},
101 {"Ð", "\303\220"},
102 {"Ñ", "\303\221"},
103 {"Ò", "\303\222"},
104 {"Ó", "\303\223"},
105 {"Ô", "\303\224"},
106 {"Õ", "\303\225"},
107 {"Ö", "\303\226"},
108 {"×", "\303\227"},
109 {"Ø", "\303\230"},
110 {"Ù", "\303\231"},
111 {"Ú", "\303\232"},
112 {"Û", "\303\233"},
113 {"Ü", "\303\234"},
114 {"Ý", "\303\235"},
115 {"Þ", "\303\236"},
116 {"ß", "\303\237"},
117 {"à", "\303\240"},
118 {"á", "\303\241"},
119 {"â", "\303\242"},
120 {"ã", "\303\243"},
121 {"ä", "\303\244"},
122 {"å", "\303\245"},
123 {"æ", "\303\246"},
124 {"ç", "\303\247"},
125 {"è", "\303\250"},
126 {"é", "\303\251"},
127 {"ê", "\303\252"},
128 {"ë", "\303\253"},
129 {"ì", "\303\254"},
130 {"í", "\303\255"},
131 {"î", "\303\256"},
132 {"ï", "\303\257"},
133 {"ð", "\303\260"},
134 {"ñ", "\303\261"},
135 {"ò", "\303\262"},
136 {"ó", "\303\263"},
137 {"ô", "\303\264"},
138 {"õ", "\303\265"},
139 {"ö", "\303\266"},
140 {"÷", "\303\267"},
141 {"ø", "\303\270"},
142 {"ù", "\303\271"},
143 {"ú", "\303\272"},
144 {"û", "\303\273"},
145 {"ü", "\303\274"},
146 {"ý", "\303\275"},
147 {"þ", "\303\276"},
148 {"ÿ", "\303\277"},
149 {"Œ", "\305\222"},
150 {"œ", "\305\223"},
151 {"Š", "\305\240"},
152 {"š", "\305\241"},
153 {"Ÿ", "\305\270"},
154 {"ˆ", "\313\206"},
155 {"˜", "\313\234"},
156 {" ", "\342\200\202"},
157 {" ", "\342\200\203"},
158 {" ", "\342\200\211"},
159 {"–", "\342\200\223"},
160 {"—", "\342\200\224"},
161 {"‘", "\342\200\230"},
162 {"’", "\342\200\231"},
163 {"‚", "\342\200\232"},
164 {"“", "\342\200\234"},
165 {"”", "\342\200\235"},
166 {"„", "\342\200\236"},
167 {"†", "\342\200\240"},
168 {"‡", "\342\200\241"},
169 {"•", "\342\200\242"},
170 {"…", "\342\200\246"},
171 {"‰", "\342\200\260"},
172 {"‹", "\342\200\271"},
173 {"›", "\342\200\272"},
174 {"€", "\342\202\254"},
175 {"™", "\342\204\242"},
183 {"¡", "\302\241"},
184 {"¢", "\302\242"},
185 {"£", "\302\243"},
186 {"¤", "\302\244"},
187 {"¥", "\302\245"},
188 {"¦", "\302\246"},
189 {"§", "\302\247"},
190 {"¨", "\302\250"},
191 {"©", "\302\251"},
192 {"ª", "\302\252"},
193 {"«", "\302\253"},
194 {"¬", "\302\254"},
195 {"­", "\302\255"},
196 {"®", "\302\256"},
197 {"¯", "\302\257"},
198 {"°", "\302\260"},
199 {"±", "\302\261"},
200 {"²", "\302\262"},
201 {"³", "\302\263"},
202 {"´", "\302\264"},
203 {"µ", "\302\265"},
204 {"¶", "\302\266"},
205 {"·", "\302\267"},
206 {"¸", "\302\270"},
207 {"¹", "\302\271"},
208 {"º", "\302\272"},
209 {"»", "\302\273"},
210 {"¼", "\302\274"},
211 {"½", "\302\275"},
212 {"¾", "\302\276"},
213 {"¿", "\302\277"},
214 {"À", "\303\200"},
215 {"Á", "\303\201"},
216 {"Â", "\303\202"},
217 {"Ã", "\303\203"},
218 {"Ä", "\303\204"},
219 {"Å", "\303\205"},
220 {"Æ", "\303\206"},
221 {"Ç", "\303\207"},
222 {"È", "\303\210"},
223 {"É", "\303\211"},
224 {"Ê", "\303\212"},
225 {"Ë", "\303\213"},
226 {"Ì", "\303\214"},
227 {"Í", "\303\215"},
228 {"Î", "\303\216"},
229 {"Ï", "\303\217"},
230 {"Ð", "\303\220"},
231 {"Ñ", "\303\221"},
232 {"Ò", "\303\222"},
233 {"Ó", "\303\223"},
234 {"Ô", "\303\224"},
235 {"Õ", "\303\225"},
236 {"Ö", "\303\226"},
237 {"×", "\303\227"},
238 {"Ø", "\303\230"},
239 {"Ù", "\303\231"},
240 {"Ú", "\303\232"},
241 {"Û", "\303\233"},
242 {"Ü", "\303\234"},
243 {"Ý", "\303\235"},
244 {"Þ", "\303\236"},
245 {"ß", "\303\237"},
246 {"à", "\303\240"},
247 {"á", "\303\241"},
248 {"â", "\303\242"},
249 {"ã", "\303\243"},
250 {"ä", "\303\244"},
251 {"å", "\303\245"},
252 {"æ", "\303\246"},
253 {"ç", "\303\247"},
254 {"è", "\303\250"},
255 {"é", "\303\251"},
256 {"ê", "\303\252"},
257 {"ë", "\303\253"},
258 {"ì", "\303\254"},
259 {"í", "\303\255"},
260 {"î", "\303\256"},
261 {"ï", "\303\257"},
262 {"ð", "\303\260"},
263 {"ñ", "\303\261"},
264 {"ò", "\303\262"},
265 {"ó", "\303\263"},
266 {"ô", "\303\264"},
267 {"õ", "\303\265"},
268 {"ö", "\303\266"},
269 {"÷", "\303\267"},
270 {"ø", "\303\270"},
271 {"ù", "\303\271"},
272 {"ú", "\303\272"},
273 {"û", "\303\273"},
274 {"ü", "\303\274"},
275 {"ý", "\303\275"},
276 {"þ", "\303\276"},
277 {"ÿ", "\303\277"},
278 {"Œ", "\305\222"},
279 {"œ", "\305\223"},
280 {"Š", "\305\240"},
281 {"š", "\305\241"},
282 {"Ÿ", "\305\270"},
283 {"ˆ", "\313\206"},
284 {"˜", "\313\234"},
285 {" ", "\342\200\202"},
286 {" ", "\342\200\203"},
287 {" ", "\342\200\211"},
288 {"–", "\342\200\223"},
289 {"—", "\342\200\224"},
290 {"‘", "\342\200\230"},
291 {"’", "\342\200\231"},
292 {"‚", "\342\200\232"},
293 {"“", "\342\200\234"},
294 {"”", "\342\200\235"},
295 {"„", "\342\200\236"},
296 {"†", "\342\200\240"},
297 {"‡", "\342\200\241"},
298 {"•", "\342\200\242"},
299 {"…", "\342\200\246"},
300 {"‰", "\342\200\260"},
301 {"‹", "\342\200\271"},
302 {"›", "\342\200\272"},
303 {"€", "\342\202\254"},
304 {"™", "\342\204\242"}
307 typedef struct _SC_HTMLAltSymbol SC_HTMLAltSymbol
;
309 struct _SC_HTMLAltSymbol
315 static GHashTable
*default_symbol_table
;
317 static SC_HTMLState
sc_html_read_line (SC_HTMLParser
*parser
);
318 static void sc_html_append_char (SC_HTMLParser
*parser
,
320 static void sc_html_append_str (SC_HTMLParser
*parser
,
323 static SC_HTMLState
sc_html_parse_tag (SC_HTMLParser
*parser
);
324 static void sc_html_parse_special (SC_HTMLParser
*parser
);
325 static void sc_html_get_parenthesis (SC_HTMLParser
*parser
,
330 SC_HTMLParser
*sc_html_parser_new(FILE *fp
, CodeConverter
*conv
)
332 SC_HTMLParser
*parser
;
334 cm_return_val_if_fail(fp
!= NULL
, NULL
);
335 cm_return_val_if_fail(conv
!= NULL
, NULL
);
337 parser
= g_new0(SC_HTMLParser
, 1);
340 parser
->str
= g_string_new(NULL
);
341 parser
->buf
= g_string_new(NULL
);
342 parser
->bufp
= parser
->buf
->str
;
343 parser
->state
= SC_HTML_NORMAL
;
345 parser
->newline
= TRUE
;
346 parser
->empty_line
= TRUE
;
347 parser
->space
= FALSE
;
351 #define SYMBOL_TABLE_ADD(table, list) \
355 for (i = 0; i < sizeof(list) / sizeof(list[0]); i++) \
356 g_hash_table_insert(table, list[i].key, list[i].val); \
358 #define SYMBOL_TABLE_REF_ADD(table, list) \
362 for (i = 0; i < sizeof(list) / sizeof(list[0]); i++) \
363 g_hash_table_insert(table, &list[i].key, list[i].val); \
366 if (!default_symbol_table
) {
367 default_symbol_table
=
368 g_hash_table_new(g_str_hash
, g_str_equal
);
369 SYMBOL_TABLE_ADD(default_symbol_table
, symbol_list
);
372 #undef SYMBOL_TABLE_ADD
373 #undef SYMBOL_TABLE_REF_ADD
375 parser
->symbol_table
= default_symbol_table
;
380 void sc_html_parser_destroy(SC_HTMLParser
*parser
)
382 g_string_free(parser
->str
, TRUE
);
383 g_string_free(parser
->buf
, TRUE
);
384 g_free(parser
->href
);
388 gchar
*sc_html_parse(SC_HTMLParser
*parser
)
390 parser
->state
= SC_HTML_NORMAL
;
391 g_string_truncate(parser
->str
, 0);
393 if (*parser
->bufp
== '\0') {
394 g_string_truncate(parser
->buf
, 0);
395 parser
->bufp
= parser
->buf
->str
;
396 if (sc_html_read_line(parser
) == SC_HTML_EOF
)
400 while (*parser
->bufp
!= '\0') {
401 switch (*parser
->bufp
) {
404 st
= sc_html_parse_tag(parser
);
405 /* when we see an href, we need to flush the str
406 * buffer. Then collect all the chars until we
407 * see the end anchor tag
409 if (SC_HTML_HREF_BEG
== st
|| SC_HTML_HREF
== st
)
410 return parser
->str
->str
;
414 sc_html_parse_special(parser
);
420 if (parser
->bufp
[0] == '\r' && parser
->bufp
[1] == '\n')
424 if (!parser
->newline
)
425 parser
->space
= TRUE
;
432 sc_html_append_char(parser
, *parser
->bufp
++);
436 return parser
->str
->str
;
439 static SC_HTMLState
sc_html_read_line(SC_HTMLParser
*parser
)
441 gchar buf
[SC_HTMLBUFSIZE
];
442 gchar buf2
[SC_HTMLBUFSIZE
];
446 if (parser
->fp
== NULL
)
449 n
= fread(buf
, 1, sizeof(buf
) - 1, parser
->fp
);
451 parser
->state
= SC_HTML_EOF
;
456 if (conv_convert(parser
->conv
, buf2
, sizeof(buf2
), buf
) < 0) {
457 index
= parser
->bufp
- parser
->buf
->str
;
459 conv_utf8todisp(buf2
, sizeof(buf2
), buf
);
460 g_string_append(parser
->buf
, buf2
);
462 parser
->bufp
= parser
->buf
->str
+ index
;
464 return SC_HTML_CONV_FAILED
;
467 index
= parser
->bufp
- parser
->buf
->str
;
469 g_string_append(parser
->buf
, buf2
);
471 parser
->bufp
= parser
->buf
->str
+ index
;
473 return SC_HTML_NORMAL
;
476 static void sc_html_append_char(SC_HTMLParser
*parser
, gchar ch
)
478 GString
*str
= parser
->str
;
480 if (!parser
->pre
&& parser
->space
) {
481 g_string_append_c(str
, ' ');
482 parser
->space
= FALSE
;
485 g_string_append_c(str
, ch
);
487 parser
->empty_line
= FALSE
;
489 parser
->newline
= TRUE
;
490 if (str
->len
> 1 && str
->str
[str
->len
- 2] == '\n')
491 parser
->empty_line
= TRUE
;
492 if (parser
->indent
> 0) {
493 gint i
, n
= parser
->indent
;
494 for (i
= 0; i
< n
; i
++)
495 g_string_append_c(str
, '>');
496 g_string_append_c(str
, ' ');
499 parser
->newline
= FALSE
;
502 static void sc_html_append_str(SC_HTMLParser
*parser
, const gchar
*str
, gint len
)
504 GString
*string
= parser
->str
;
506 if (!parser
->pre
&& parser
->space
) {
507 g_string_append_c(string
, ' ');
508 parser
->space
= FALSE
;
511 if (len
== 0) return;
513 g_string_append(string
, str
);
516 Xstrndup_a(s
, str
, len
, return);
517 g_string_append(string
, s
);
520 parser
->empty_line
= FALSE
;
521 if (string
->len
> 0 && string
->str
[string
->len
- 1] == '\n') {
522 parser
->newline
= TRUE
;
523 if (string
->len
> 1 && string
->str
[string
->len
- 2] == '\n')
524 parser
->empty_line
= TRUE
;
526 parser
->newline
= FALSE
;
529 static SC_HTMLTag
*sc_html_get_tag(const gchar
*str
)
535 cm_return_val_if_fail(str
!= NULL
, NULL
);
537 if (*str
== '\0' || *str
== '!') return NULL
;
539 Xstrdup_a(tmp
, str
, return NULL
);
541 tag
= g_new0(SC_HTMLTag
, 1);
543 for (tmpp
= tmp
; *tmpp
!= '\0' && !g_ascii_isspace(*tmpp
); tmpp
++)
547 tag
->name
= g_utf8_strdown(tmp
, -1);
551 tag
->name
= g_utf8_strdown(tmp
, -1);
554 while (*tmpp
!= '\0') {
561 while (g_ascii_isspace(*tmpp
)) tmpp
++;
564 while (*tmpp
!= '\0' && !g_ascii_isspace(*tmpp
) &&
567 if (*tmpp
!= '\0' && *tmpp
!= '=') {
569 while (g_ascii_isspace(*tmpp
)) tmpp
++;
574 while (g_ascii_isspace(*tmpp
)) tmpp
++;
576 if (*tmpp
== '"' || *tmpp
== '\'') {
581 if ((p
= strchr(attr_value
, quote
)) == NULL
) {
582 g_warning("sc_html_get_tag(): syntax error in tag: '%s'", str
);
587 while (g_ascii_isspace(*tmpp
)) tmpp
++;
591 while (*tmpp
!= '\0' && !g_ascii_isspace(*tmpp
)) tmpp
++;
598 g_strchomp(attr_name
);
599 attr
= g_new(SC_HTMLAttr
, 1);
600 attr
->name
= g_utf8_strdown(attr_name
, -1);
601 attr
->value
= g_strdup(attr_value
);
602 tag
->attr
= g_list_append(tag
->attr
, attr
);
608 static void sc_html_free_tag(SC_HTMLTag
*tag
)
613 while (tag
->attr
!= NULL
) {
614 SC_HTMLAttr
*attr
= (SC_HTMLAttr
*)tag
->attr
->data
;
618 tag
->attr
= g_list_remove(tag
->attr
, tag
->attr
->data
);
623 static void decode_href(SC_HTMLParser
*parser
)
626 SC_HTMLParser
*tparser
= g_new0(SC_HTMLParser
, 1);
628 tparser
->str
= g_string_new(NULL
);
629 tparser
->buf
= g_string_new(parser
->href
);
630 tparser
->bufp
= tparser
->buf
->str
;
631 tparser
->symbol_table
= default_symbol_table
;
633 tmp
= sc_html_parse(tparser
);
635 g_free(parser
->href
);
636 parser
->href
= g_strdup(tmp
);
638 sc_html_parser_destroy(tparser
);
641 static SC_HTMLState
sc_html_parse_tag(SC_HTMLParser
*parser
)
643 gchar buf
[SC_HTMLBUFSIZE
];
646 sc_html_get_parenthesis(parser
, buf
, sizeof(buf
));
648 tag
= sc_html_get_tag(buf
);
650 parser
->state
= SC_HTML_UNKNOWN
;
651 if (!tag
) return SC_HTML_UNKNOWN
;
653 if (!strcmp(tag
->name
, "br") || !strcmp(tag
->name
, "br/")) {
654 parser
->space
= FALSE
;
655 sc_html_append_char(parser
, '\n');
656 parser
->state
= SC_HTML_BR
;
657 } else if (!strcmp(tag
->name
, "a")) {
660 for (cur
= tag
->attr
; cur
!= NULL
; cur
= cur
->next
) {
661 if (cur
->data
&& !strcmp(((SC_HTMLAttr
*)cur
->data
)->name
, "href")) {
662 g_free(parser
->href
);
663 parser
->href
= g_strdup(((SC_HTMLAttr
*)cur
->data
)->value
);
665 parser
->state
= SC_HTML_HREF_BEG
;
669 if (parser
->href
== NULL
)
670 parser
->href
= g_strdup("");
671 parser
->state
= SC_HTML_HREF_BEG
;
672 } else if (!strcmp(tag
->name
, "/a")) {
673 parser
->state
= SC_HTML_HREF
;
674 } else if (!strcmp(tag
->name
, "p")) {
675 parser
->space
= FALSE
;
676 if (!parser
->empty_line
) {
677 parser
->space
= FALSE
;
678 if (!parser
->newline
) sc_html_append_char(parser
, '\n');
679 sc_html_append_char(parser
, '\n');
681 parser
->state
= SC_HTML_PAR
;
682 } else if (!strcmp(tag
->name
, "pre")) {
684 parser
->state
= SC_HTML_PRE
;
685 } else if (!strcmp(tag
->name
, "/pre")) {
687 parser
->state
= SC_HTML_NORMAL
;
688 } else if (!strcmp(tag
->name
, "hr")) {
689 if (!parser
->newline
) {
690 parser
->space
= FALSE
;
691 sc_html_append_char(parser
, '\n');
693 sc_html_append_str(parser
, HR_STR
, -1);
694 sc_html_append_char(parser
, '\n');
695 parser
->state
= SC_HTML_HR
;
696 } else if (!strcmp(tag
->name
, "div") ||
697 !strcmp(tag
->name
, "ul") ||
698 !strcmp(tag
->name
, "li") ||
699 !strcmp(tag
->name
, "table") ||
700 !strcmp(tag
->name
, "dd") ||
701 !strcmp(tag
->name
, "tr") ||
702 (tag
->name
[0] == 'h' && g_ascii_isdigit(tag
->name
[1]))) {
703 if (!parser
->newline
) {
704 parser
->space
= FALSE
;
705 sc_html_append_char(parser
, '\n');
707 if (!strcmp(tag
->name
, "li")) {
708 sc_html_append_str(parser
, LI_STR
, -1);
710 parser
->state
= SC_HTML_NORMAL
;
711 } else if (!strcmp(tag
->name
, "blockquote")) {
712 parser
->state
= SC_HTML_NORMAL
;
714 } else if (!strcmp(tag
->name
, "/blockquote")) {
715 parser
->state
= SC_HTML_NORMAL
;
717 } else if (!strcmp(tag
->name
, "/table") ||
718 (tag
->name
[0] == '/' &&
719 tag
->name
[1] == 'h' &&
720 g_ascii_isdigit(tag
->name
[1]))) {
721 if (!parser
->empty_line
) {
722 parser
->space
= FALSE
;
723 if (!parser
->newline
) sc_html_append_char(parser
, '\n');
724 sc_html_append_char(parser
, '\n');
726 parser
->state
= SC_HTML_NORMAL
;
727 } else if (!strcmp(tag
->name
, "/div") ||
728 !strcmp(tag
->name
, "/ul") ||
729 !strcmp(tag
->name
, "/li")) {
730 if (!parser
->newline
) {
731 parser
->space
= FALSE
;
732 sc_html_append_char(parser
, '\n');
734 parser
->state
= SC_HTML_NORMAL
;
737 sc_html_free_tag(tag
);
739 return parser
->state
;
742 static void sc_html_parse_special(SC_HTMLParser
*parser
)
744 gchar symbol_name
[9];
748 parser
->state
= SC_HTML_UNKNOWN
;
749 cm_return_if_fail(*parser
->bufp
== '&');
752 for (n
= 0; parser
->bufp
[n
] != '\0' && parser
->bufp
[n
] != ';'; n
++)
754 if (n
> 7 || parser
->bufp
[n
] != ';') {
755 /* output literal `&' */
756 sc_html_append_char(parser
, *parser
->bufp
++);
757 parser
->state
= SC_HTML_NORMAL
;
760 strncpy2(symbol_name
, parser
->bufp
, n
+ 2);
761 parser
->bufp
+= n
+ 1;
763 if ((val
= g_hash_table_lookup(parser
->symbol_table
, symbol_name
))
765 sc_html_append_str(parser
, val
, -1);
766 parser
->state
= SC_HTML_NORMAL
;
770 sc_html_append_str(parser
, symbol_name
, -1);
773 static gchar
*sc_html_find_tag(SC_HTMLParser
*parser
, const gchar
*tag
)
775 gchar
*cur
= parser
->bufp
;
776 gint len
= strlen(tag
);
781 while ((cur
= strstr(cur
, "<")) != NULL
) {
782 if (!g_ascii_strncasecmp(cur
, tag
, len
))
789 static void sc_html_get_parenthesis(SC_HTMLParser
*parser
, gchar
*buf
, gint len
)
794 cm_return_if_fail(*parser
->bufp
== '<');
796 /* ignore comment / CSS / script stuff */
797 if (!strncmp(parser
->bufp
, "<!--", 4)) {
799 while ((p
= strstr(parser
->bufp
, "-->")) == NULL
)
800 if (sc_html_read_line(parser
) == SC_HTML_EOF
) return;
801 parser
->bufp
= p
+ 3;
804 if (!g_ascii_strncasecmp(parser
->bufp
, "<style", 6)) {
806 while ((p
= sc_html_find_tag(parser
, "</style>")) == NULL
)
807 if (sc_html_read_line(parser
) == SC_HTML_EOF
) return;
808 parser
->bufp
= p
+ 8;
811 if (!g_ascii_strncasecmp(parser
->bufp
, "<script", 7)) {
813 while ((p
= sc_html_find_tag(parser
, "</script>")) == NULL
)
814 if (sc_html_read_line(parser
) == SC_HTML_EOF
) return;
815 parser
->bufp
= p
+ 9;
820 while ((p
= strchr(parser
->bufp
, '>')) == NULL
)
821 if (sc_html_read_line(parser
) == SC_HTML_EOF
) return;
823 strncpy2(buf
, parser
->bufp
, MIN(p
- parser
->bufp
+ 1, len
));
825 parser
->bufp
= p
+ 1;