mirror of
https://github.com/rkd77/elinks.git
synced 2025-06-30 22:19:29 -04:00
Merge with git+ssh://pasky.or.cz/srv/git/elinks.git
This commit is contained in:
commit
6edbc346e0
@ -262,193 +262,6 @@ html_skip(struct html_context *html_context, unsigned char *a)
|
|||||||
html_top.type = ELEMENT_DONT_KILL;
|
html_top.type = ELEMENT_DONT_KILL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_ECMASCRIPT
|
|
||||||
int
|
|
||||||
do_html_script(struct html_context *html_context, unsigned char *a,
|
|
||||||
unsigned char *html, unsigned char *eof, unsigned char **end)
|
|
||||||
{
|
|
||||||
/* TODO: <noscript> processing. Well, same considerations apply as to
|
|
||||||
* CSS property display: none processing. */
|
|
||||||
/* TODO: Charsets for external scripts. */
|
|
||||||
unsigned char *type, *language, *src;
|
|
||||||
int in_comment = 0;
|
|
||||||
|
|
||||||
html_skip(html_context, a);
|
|
||||||
|
|
||||||
/* We try to process nested <script> if we didn't process the parent
|
|
||||||
* one. That's why's all the fuzz. */
|
|
||||||
/* Ref:
|
|
||||||
* http://www.ietf.org/internet-drafts/draft-hoehrmann-script-types-03.txt
|
|
||||||
*/
|
|
||||||
type = get_attr_val(a, "type", html_context->options);
|
|
||||||
if (type) {
|
|
||||||
unsigned char *pos = type;
|
|
||||||
|
|
||||||
if (!strncasecmp(type, "text/", 5)) {
|
|
||||||
pos += 5;
|
|
||||||
|
|
||||||
} else if (!strncasecmp(type, "application/", 12)) {
|
|
||||||
pos += 12;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
mem_free(type);
|
|
||||||
not_processed:
|
|
||||||
/* Permit nested scripts and retreat. */
|
|
||||||
html_top.invisible++;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!strncasecmp(pos, "javascript", 10)) {
|
|
||||||
int len = strlen(pos);
|
|
||||||
|
|
||||||
if (len > 10 && !isdigit(pos[10])) {
|
|
||||||
mem_free(type);
|
|
||||||
goto not_processed;
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if (strcasecmp(pos, "ecmascript")
|
|
||||||
&& strcasecmp(pos, "jscript")
|
|
||||||
&& strcasecmp(pos, "livescript")
|
|
||||||
&& strcasecmp(pos, "x-javascript")
|
|
||||||
&& strcasecmp(pos, "x-ecmascript")) {
|
|
||||||
mem_free(type);
|
|
||||||
goto not_processed;
|
|
||||||
}
|
|
||||||
|
|
||||||
mem_free(type);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Check that the script content is ecmascript. The value of the
|
|
||||||
* language attribute can be JavaScript with optional version digits
|
|
||||||
* postfixed (like: ``JavaScript1.1'').
|
|
||||||
* That attribute is deprecated in favor of type by HTML 4.01 */
|
|
||||||
language = get_attr_val(a, "language", html_context->options);
|
|
||||||
if (language) {
|
|
||||||
int languagelen = strlen(language);
|
|
||||||
|
|
||||||
if (languagelen < 10
|
|
||||||
|| (languagelen > 10 && !isdigit(language[10]))
|
|
||||||
|| strncasecmp(language, "javascript", 10)) {
|
|
||||||
mem_free(language);
|
|
||||||
goto not_processed;
|
|
||||||
}
|
|
||||||
|
|
||||||
mem_free(language);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (html_context->part->document
|
|
||||||
&& (src = get_attr_val(a, "src", html_context->options))) {
|
|
||||||
/* External reference. */
|
|
||||||
|
|
||||||
unsigned char *import_url;
|
|
||||||
struct uri *uri;
|
|
||||||
|
|
||||||
if (!get_opt_bool("ecmascript.enable")) {
|
|
||||||
mem_free(src);
|
|
||||||
goto not_processed;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* HTML <head> urls should already be fine but we can.t detect them. */
|
|
||||||
import_url = join_urls(html_context->base_href, src);
|
|
||||||
mem_free(src);
|
|
||||||
if (!import_url) goto imported;
|
|
||||||
|
|
||||||
uri = get_uri(import_url, URI_BASE);
|
|
||||||
if (!uri) goto imported;
|
|
||||||
|
|
||||||
/* Request the imported script as part of the document ... */
|
|
||||||
html_context->special_f(html_context, SP_SCRIPT, uri);
|
|
||||||
done_uri(uri);
|
|
||||||
|
|
||||||
/* Create URL reference onload snippet. */
|
|
||||||
insert_in_string(&import_url, 0, "^", 1);
|
|
||||||
add_to_string_list(&html_context->part->document->onload_snippets,
|
|
||||||
import_url, -1);
|
|
||||||
|
|
||||||
imported:
|
|
||||||
/* Retreat. Do not permit nested scripts, tho'. */
|
|
||||||
if (import_url) mem_free(import_url);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Positive, grab the rest and interpret it. */
|
|
||||||
|
|
||||||
/* First position to the real script start. */
|
|
||||||
while (html < eof && *html <= ' ') html++;
|
|
||||||
if (eof - html > 4 && !strncmp(html, "<!--", 4)) {
|
|
||||||
in_comment = 1;
|
|
||||||
/* We either skip to the end of line or to -->. */
|
|
||||||
for (; *html != '\n' && *html != '\r' && eof - html >= 3; html++) {
|
|
||||||
if (!strncmp(html, "-->", 3)) {
|
|
||||||
/* This means the document is probably broken.
|
|
||||||
* We will now try to process the rest of
|
|
||||||
* <script> contents, which is however likely
|
|
||||||
* to be empty. Should we try to process the
|
|
||||||
* comment too? Currently it seems safer but
|
|
||||||
* less tolerant to broken pages, if there are
|
|
||||||
* any like this. */
|
|
||||||
html += 3;
|
|
||||||
in_comment = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
*end = html;
|
|
||||||
|
|
||||||
/* Now look ahead for the script end. The <script> contents is raw
|
|
||||||
* CDATA, so we just look for the ending tag and need not care for
|
|
||||||
* any quote marks counting etc - YET, we are more tolerant and permit
|
|
||||||
* </script> stuff inside of the script if the whole <script> element
|
|
||||||
* contents is wrapped in a comment. See i.e. Mozilla bug 26857 for fun
|
|
||||||
* reading regarding this. */
|
|
||||||
for (; *end < eof; (*end)++) {
|
|
||||||
unsigned char *name;
|
|
||||||
int namelen;
|
|
||||||
|
|
||||||
if (in_comment) {
|
|
||||||
/* TODO: If we ever get some standards-quirk mode
|
|
||||||
* distinction, this should be disabled in the
|
|
||||||
* standards mode (and we should just look for CDATA
|
|
||||||
* end, which is "</"). --pasky */
|
|
||||||
if (eof - *end >= 3 && !strncmp(*end, "-->", 3)) {
|
|
||||||
/* Next iteration will jump passed the ending '>' */
|
|
||||||
(*end) += 2;
|
|
||||||
in_comment = 0;
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
/* XXX: Scan for another comment? That's admittelly
|
|
||||||
* already stretching things a little bit to an
|
|
||||||
* extreme ;-). */
|
|
||||||
}
|
|
||||||
|
|
||||||
if (**end != '<')
|
|
||||||
continue;
|
|
||||||
/* We want to land before the closing element, that's why we
|
|
||||||
* don't pass @end also as the appropriate parse_element()
|
|
||||||
* argument. */
|
|
||||||
if (parse_element(*end, eof, &name, &namelen, NULL, NULL))
|
|
||||||
continue;
|
|
||||||
if (strlcasecmp(name, namelen, "/script", 7))
|
|
||||||
continue;
|
|
||||||
/* We have won! */
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (*end >= eof) {
|
|
||||||
/* Either the document is not completely loaded yet or it's
|
|
||||||
* broken. At any rate, run away screaming. */
|
|
||||||
*end = eof; /* Just for sanity. */
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (html_context->part->document && *html != '^') {
|
|
||||||
add_to_string_list(&html_context->part->document->onload_snippets,
|
|
||||||
html, *end - html);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void
|
void
|
||||||
process_head(struct html_context *html_context, unsigned char *head)
|
process_head(struct html_context *html_context, unsigned char *head)
|
||||||
{
|
{
|
||||||
|
@ -207,8 +207,4 @@ void ln_break(struct html_context *html_context, int n);
|
|||||||
|
|
||||||
int get_color(struct html_context *html_context, unsigned char *a, unsigned char *c, color_T *rgb);
|
int get_color(struct html_context *html_context, unsigned char *a, unsigned char *c, color_T *rgb);
|
||||||
|
|
||||||
#ifdef CONFIG_ECMASCRIPT
|
|
||||||
int do_html_script(struct html_context *html_context, unsigned char *attr, unsigned char *html, unsigned char *eof, unsigned char **end);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -298,105 +298,9 @@ hid:
|
|||||||
html_context->special_f(html_context, SP_CONTROL, fc);
|
html_context->special_f(html_context, SP_CONTROL, fc);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
html_select(struct html_context *html_context, unsigned char *a,
|
|
||||||
unsigned char *html, unsigned char *eof, unsigned char **end)
|
|
||||||
{
|
|
||||||
unsigned char *al;
|
|
||||||
|
|
||||||
if (!do_html_select(a, html, eof, end, html_context))
|
|
||||||
return;
|
|
||||||
|
|
||||||
al = get_attr_val(a, "name", html_context->options);
|
|
||||||
if (!al) return;
|
|
||||||
|
|
||||||
html_focusable(html_context, a);
|
|
||||||
html_top.type = ELEMENT_DONT_KILL;
|
|
||||||
mem_free_set(&format.select, al);
|
|
||||||
format.select_disabled = has_attr(a, "disabled", html_context->options)
|
|
||||||
? FORM_MODE_DISABLED
|
|
||||||
: FORM_MODE_NORMAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
html_option(struct html_context *html_context, unsigned char *a,
|
|
||||||
unsigned char *xxx3, unsigned char *xxx4, unsigned char **xxx5)
|
|
||||||
{
|
|
||||||
struct form_control *fc;
|
|
||||||
unsigned char *val;
|
|
||||||
|
|
||||||
if (!format.select) return;
|
|
||||||
|
|
||||||
val = get_attr_val(a, "value", html_context->options);
|
|
||||||
if (!val) {
|
|
||||||
struct string str;
|
|
||||||
unsigned char *p, *r;
|
|
||||||
unsigned char *name;
|
|
||||||
int namelen;
|
|
||||||
|
|
||||||
for (p = a - 1; *p != '<'; p--);
|
|
||||||
|
|
||||||
if (!init_string(&str)) goto end_parse;
|
|
||||||
if (parse_element(p, html_context->eoff, NULL, NULL, NULL, &p)) {
|
|
||||||
INTERNAL("parse element failed");
|
|
||||||
val = str.source;
|
|
||||||
goto end_parse;
|
|
||||||
}
|
|
||||||
|
|
||||||
se:
|
|
||||||
while (p < html_context->eoff && isspace(*p)) p++;
|
|
||||||
while (p < html_context->eoff && !isspace(*p) && *p != '<') {
|
|
||||||
|
|
||||||
sp:
|
|
||||||
add_char_to_string(&str, *p ? *p : ' '), p++;
|
|
||||||
}
|
|
||||||
|
|
||||||
r = p;
|
|
||||||
val = str.source; /* Has to be before the possible 'goto end_parse' */
|
|
||||||
|
|
||||||
while (r < html_context->eoff && isspace(*r)) r++;
|
|
||||||
if (r >= html_context->eoff) goto end_parse;
|
|
||||||
if (r - 2 <= html_context->eoff && (r[1] == '!' || r[1] == '?')) {
|
|
||||||
p = skip_comment(r, html_context->eoff);
|
|
||||||
goto se;
|
|
||||||
}
|
|
||||||
if (parse_element(r, html_context->eoff, &name, &namelen, NULL, &p)) goto sp;
|
|
||||||
if (strlcasecmp(name, namelen, "OPTION", 6)
|
|
||||||
&& strlcasecmp(name, namelen, "/OPTION", 7)
|
|
||||||
&& strlcasecmp(name, namelen, "SELECT", 6)
|
|
||||||
&& strlcasecmp(name, namelen, "/SELECT", 7)
|
|
||||||
&& strlcasecmp(name, namelen, "OPTGROUP", 8)
|
|
||||||
&& strlcasecmp(name, namelen, "/OPTGROUP", 9))
|
|
||||||
goto se;
|
|
||||||
}
|
|
||||||
|
|
||||||
end_parse:
|
|
||||||
fc = init_form_control(FC_CHECKBOX, a, html_context);
|
|
||||||
if (!fc) {
|
|
||||||
mem_free_if(val);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
fc->name = null_or_stracpy(format.select);
|
|
||||||
fc->default_value = val;
|
|
||||||
fc->default_state = has_attr(a, "selected", html_context->options);
|
|
||||||
fc->mode = has_attr(a, "disabled", html_context->options)
|
|
||||||
? FORM_MODE_DISABLED
|
|
||||||
: format.select_disabled;
|
|
||||||
|
|
||||||
put_chrs(html_context, " ", 1);
|
|
||||||
html_stack_dup(html_context, ELEMENT_KILLABLE);
|
|
||||||
format.form = fc;
|
|
||||||
format.style.attr |= AT_BOLD;
|
|
||||||
put_chrs(html_context, "[ ]", 3);
|
|
||||||
kill_html_stack_item(html_context, &html_top);
|
|
||||||
put_chrs(html_context, " ", 1);
|
|
||||||
html_context->special_f(html_context, SP_CONTROL, fc);
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct list_menu lnk_menu;
|
static struct list_menu lnk_menu;
|
||||||
|
|
||||||
int
|
static void
|
||||||
do_html_select(unsigned char *attr, unsigned char *html,
|
do_html_select(unsigned char *attr, unsigned char *html,
|
||||||
unsigned char *eof, unsigned char **end,
|
unsigned char *eof, unsigned char **end,
|
||||||
struct html_context *html_context)
|
struct html_context *html_context)
|
||||||
@ -414,7 +318,6 @@ do_html_select(unsigned char *attr, unsigned char *html,
|
|||||||
int group = 0;
|
int group = 0;
|
||||||
int i, max_width;
|
int i, max_width;
|
||||||
|
|
||||||
if (has_attr(attr, "multiple", html_context->options)) return 1;
|
|
||||||
html_focusable(html_context, attr);
|
html_focusable(html_context, attr);
|
||||||
init_menu(&lnk_menu);
|
init_menu(&lnk_menu);
|
||||||
|
|
||||||
@ -440,7 +343,7 @@ abort:
|
|||||||
}
|
}
|
||||||
destroy_menu(&lnk_menu);
|
destroy_menu(&lnk_menu);
|
||||||
*end = en;
|
*end = en;
|
||||||
return 0;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lbl.source) {
|
if (lbl.source) {
|
||||||
@ -563,20 +466,115 @@ end_parse:
|
|||||||
kill_html_stack_item(html_context, &html_top);
|
kill_html_stack_item(html_context, &html_top);
|
||||||
put_chrs(html_context, "]", 1);
|
put_chrs(html_context, "]", 1);
|
||||||
html_context->special_f(html_context, SP_CONTROL, fc);
|
html_context->special_f(html_context, SP_CONTROL, fc);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
|
||||||
|
static void
|
||||||
|
do_html_select_multiple(struct html_context *html_context, unsigned char *a,
|
||||||
|
unsigned char *html, unsigned char *eof,
|
||||||
|
unsigned char **end)
|
||||||
|
{
|
||||||
|
unsigned char *al = get_attr_val(a, "name", html_context->options);
|
||||||
|
|
||||||
|
if (!al) return;
|
||||||
|
html_focusable(html_context, a);
|
||||||
|
html_top.type = ELEMENT_DONT_KILL;
|
||||||
|
mem_free_set(&format.select, al);
|
||||||
|
format.select_disabled = has_attr(a, "disabled", html_context->options)
|
||||||
|
? FORM_MODE_DISABLED
|
||||||
|
: FORM_MODE_NORMAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
html_textarea(struct html_context *html_context, unsigned char *a,
|
html_select(struct html_context *html_context, unsigned char *a,
|
||||||
unsigned char *html, unsigned char *eof, unsigned char **end)
|
unsigned char *html, unsigned char *eof, unsigned char **end)
|
||||||
{
|
{
|
||||||
do_html_textarea(a, html, eof, end, html_context);
|
if (has_attr(a, "multiple", html_context->options))
|
||||||
|
do_html_select_multiple(html_context, a, html, eof, end);
|
||||||
|
else
|
||||||
|
do_html_select(a, html, eof, end, html_context);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
do_html_textarea(unsigned char *attr, unsigned char *html, unsigned char *eof,
|
html_option(struct html_context *html_context, unsigned char *a,
|
||||||
unsigned char **end, struct html_context *html_context)
|
unsigned char *xxx3, unsigned char *xxx4, unsigned char **xxx5)
|
||||||
|
{
|
||||||
|
struct form_control *fc;
|
||||||
|
unsigned char *val;
|
||||||
|
|
||||||
|
if (!format.select) return;
|
||||||
|
|
||||||
|
val = get_attr_val(a, "value", html_context->options);
|
||||||
|
if (!val) {
|
||||||
|
struct string str;
|
||||||
|
unsigned char *p, *r;
|
||||||
|
unsigned char *name;
|
||||||
|
int namelen;
|
||||||
|
|
||||||
|
for (p = a - 1; *p != '<'; p--);
|
||||||
|
|
||||||
|
if (!init_string(&str)) goto end_parse;
|
||||||
|
if (parse_element(p, html_context->eoff, NULL, NULL, NULL, &p)) {
|
||||||
|
INTERNAL("parse element failed");
|
||||||
|
val = str.source;
|
||||||
|
goto end_parse;
|
||||||
|
}
|
||||||
|
|
||||||
|
se:
|
||||||
|
while (p < html_context->eoff && isspace(*p)) p++;
|
||||||
|
while (p < html_context->eoff && !isspace(*p) && *p != '<') {
|
||||||
|
|
||||||
|
sp:
|
||||||
|
add_char_to_string(&str, *p ? *p : ' '), p++;
|
||||||
|
}
|
||||||
|
|
||||||
|
r = p;
|
||||||
|
val = str.source; /* Has to be before the possible 'goto end_parse' */
|
||||||
|
|
||||||
|
while (r < html_context->eoff && isspace(*r)) r++;
|
||||||
|
if (r >= html_context->eoff) goto end_parse;
|
||||||
|
if (r - 2 <= html_context->eoff && (r[1] == '!' || r[1] == '?')) {
|
||||||
|
p = skip_comment(r, html_context->eoff);
|
||||||
|
goto se;
|
||||||
|
}
|
||||||
|
if (parse_element(r, html_context->eoff, &name, &namelen, NULL, &p)) goto sp;
|
||||||
|
if (strlcasecmp(name, namelen, "OPTION", 6)
|
||||||
|
&& strlcasecmp(name, namelen, "/OPTION", 7)
|
||||||
|
&& strlcasecmp(name, namelen, "SELECT", 6)
|
||||||
|
&& strlcasecmp(name, namelen, "/SELECT", 7)
|
||||||
|
&& strlcasecmp(name, namelen, "OPTGROUP", 8)
|
||||||
|
&& strlcasecmp(name, namelen, "/OPTGROUP", 9))
|
||||||
|
goto se;
|
||||||
|
}
|
||||||
|
|
||||||
|
end_parse:
|
||||||
|
fc = init_form_control(FC_CHECKBOX, a, html_context);
|
||||||
|
if (!fc) {
|
||||||
|
mem_free_if(val);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
fc->name = null_or_stracpy(format.select);
|
||||||
|
fc->default_value = val;
|
||||||
|
fc->default_state = has_attr(a, "selected", html_context->options);
|
||||||
|
fc->mode = has_attr(a, "disabled", html_context->options)
|
||||||
|
? FORM_MODE_DISABLED
|
||||||
|
: format.select_disabled;
|
||||||
|
|
||||||
|
put_chrs(html_context, " ", 1);
|
||||||
|
html_stack_dup(html_context, ELEMENT_KILLABLE);
|
||||||
|
format.form = fc;
|
||||||
|
format.style.attr |= AT_BOLD;
|
||||||
|
put_chrs(html_context, "[ ]", 3);
|
||||||
|
kill_html_stack_item(html_context, &html_top);
|
||||||
|
put_chrs(html_context, " ", 1);
|
||||||
|
html_context->special_f(html_context, SP_CONTROL, fc);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
html_textarea(struct html_context *html_context, unsigned char *attr,
|
||||||
|
unsigned char *html, unsigned char *eof, unsigned char **end)
|
||||||
{
|
{
|
||||||
struct form_control *fc;
|
struct form_control *fc;
|
||||||
unsigned char *p, *t_name, *wrap_attr;
|
unsigned char *p, *t_name, *wrap_attr;
|
||||||
|
@ -13,7 +13,4 @@ element_handler_T html_select;
|
|||||||
element_handler_T html_option;
|
element_handler_T html_option;
|
||||||
element_handler_T html_textarea;
|
element_handler_T html_textarea;
|
||||||
|
|
||||||
int do_html_select(unsigned char *attr, unsigned char *html, unsigned char *eof, unsigned char **end, struct html_context *html_context);
|
|
||||||
void do_html_textarea(unsigned char *attr, unsigned char *html, unsigned char *eof, unsigned char **end, struct html_context *html_context);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -23,6 +23,8 @@
|
|||||||
#include "document/html/parser/stack.h"
|
#include "document/html/parser/stack.h"
|
||||||
#include "document/html/parser/parse.h"
|
#include "document/html/parser/parse.h"
|
||||||
#include "document/html/parser.h"
|
#include "document/html/parser.h"
|
||||||
|
#include "document/html/renderer.h"
|
||||||
|
#include "document/html/tables.h"
|
||||||
#include "document/options.h"
|
#include "document/options.h"
|
||||||
#include "intl/charsets.h"
|
#include "intl/charsets.h"
|
||||||
#include "protocol/uri.h"
|
#include "protocol/uri.h"
|
||||||
@ -164,9 +166,186 @@ html_script(struct html_context *html_context, unsigned char *a,
|
|||||||
unsigned char *html, unsigned char *eof, unsigned char **end)
|
unsigned char *html, unsigned char *eof, unsigned char **end)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_ECMASCRIPT
|
#ifdef CONFIG_ECMASCRIPT
|
||||||
do_html_script(html_context, a, html, eof, end);
|
/* TODO: <noscript> processing. Well, same considerations apply as to
|
||||||
#else
|
* CSS property display: none processing. */
|
||||||
|
/* TODO: Charsets for external scripts. */
|
||||||
|
unsigned char *type, *language, *src;
|
||||||
|
int in_comment = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
html_skip(html_context, a);
|
html_skip(html_context, a);
|
||||||
|
|
||||||
|
#ifdef CONFIG_ECMASCRIPT
|
||||||
|
/* We try to process nested <script> if we didn't process the parent
|
||||||
|
* one. That's why's all the fuzz. */
|
||||||
|
/* Ref:
|
||||||
|
* http://www.ietf.org/internet-drafts/draft-hoehrmann-script-types-03.txt
|
||||||
|
*/
|
||||||
|
type = get_attr_val(a, "type", html_context->options);
|
||||||
|
if (type) {
|
||||||
|
unsigned char *pos = type;
|
||||||
|
|
||||||
|
if (!strncasecmp(type, "text/", 5)) {
|
||||||
|
pos += 5;
|
||||||
|
|
||||||
|
} else if (!strncasecmp(type, "application/", 12)) {
|
||||||
|
pos += 12;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
mem_free(type);
|
||||||
|
not_processed:
|
||||||
|
/* Permit nested scripts and retreat. */
|
||||||
|
html_top.invisible++;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!strncasecmp(pos, "javascript", 10)) {
|
||||||
|
int len = strlen(pos);
|
||||||
|
|
||||||
|
if (len > 10 && !isdigit(pos[10])) {
|
||||||
|
mem_free(type);
|
||||||
|
goto not_processed;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (strcasecmp(pos, "ecmascript")
|
||||||
|
&& strcasecmp(pos, "jscript")
|
||||||
|
&& strcasecmp(pos, "livescript")
|
||||||
|
&& strcasecmp(pos, "x-javascript")
|
||||||
|
&& strcasecmp(pos, "x-ecmascript")) {
|
||||||
|
mem_free(type);
|
||||||
|
goto not_processed;
|
||||||
|
}
|
||||||
|
|
||||||
|
mem_free(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check that the script content is ecmascript. The value of the
|
||||||
|
* language attribute can be JavaScript with optional version digits
|
||||||
|
* postfixed (like: ``JavaScript1.1'').
|
||||||
|
* That attribute is deprecated in favor of type by HTML 4.01 */
|
||||||
|
language = get_attr_val(a, "language", html_context->options);
|
||||||
|
if (language) {
|
||||||
|
int languagelen = strlen(language);
|
||||||
|
|
||||||
|
if (languagelen < 10
|
||||||
|
|| (languagelen > 10 && !isdigit(language[10]))
|
||||||
|
|| strncasecmp(language, "javascript", 10)) {
|
||||||
|
mem_free(language);
|
||||||
|
goto not_processed;
|
||||||
|
}
|
||||||
|
|
||||||
|
mem_free(language);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (html_context->part->document
|
||||||
|
&& (src = get_attr_val(a, "src", html_context->options))) {
|
||||||
|
/* External reference. */
|
||||||
|
|
||||||
|
unsigned char *import_url;
|
||||||
|
struct uri *uri;
|
||||||
|
|
||||||
|
if (!get_opt_bool("ecmascript.enable")) {
|
||||||
|
mem_free(src);
|
||||||
|
goto not_processed;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* HTML <head> urls should already be fine but we can.t detect them. */
|
||||||
|
import_url = join_urls(html_context->base_href, src);
|
||||||
|
mem_free(src);
|
||||||
|
if (!import_url) goto imported;
|
||||||
|
|
||||||
|
uri = get_uri(import_url, URI_BASE);
|
||||||
|
if (!uri) goto imported;
|
||||||
|
|
||||||
|
/* Request the imported script as part of the document ... */
|
||||||
|
html_context->special_f(html_context, SP_SCRIPT, uri);
|
||||||
|
done_uri(uri);
|
||||||
|
|
||||||
|
/* Create URL reference onload snippet. */
|
||||||
|
insert_in_string(&import_url, 0, "^", 1);
|
||||||
|
add_to_string_list(&html_context->part->document->onload_snippets,
|
||||||
|
import_url, -1);
|
||||||
|
|
||||||
|
imported:
|
||||||
|
/* Retreat. Do not permit nested scripts, tho'. */
|
||||||
|
if (import_url) mem_free(import_url);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Positive, grab the rest and interpret it. */
|
||||||
|
|
||||||
|
/* First position to the real script start. */
|
||||||
|
while (html < eof && *html <= ' ') html++;
|
||||||
|
if (eof - html > 4 && !strncmp(html, "<!--", 4)) {
|
||||||
|
in_comment = 1;
|
||||||
|
/* We either skip to the end of line or to -->. */
|
||||||
|
for (; *html != '\n' && *html != '\r' && eof - html >= 3; html++) {
|
||||||
|
if (!strncmp(html, "-->", 3)) {
|
||||||
|
/* This means the document is probably broken.
|
||||||
|
* We will now try to process the rest of
|
||||||
|
* <script> contents, which is however likely
|
||||||
|
* to be empty. Should we try to process the
|
||||||
|
* comment too? Currently it seems safer but
|
||||||
|
* less tolerant to broken pages, if there are
|
||||||
|
* any like this. */
|
||||||
|
html += 3;
|
||||||
|
in_comment = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
*end = html;
|
||||||
|
|
||||||
|
/* Now look ahead for the script end. The <script> contents is raw
|
||||||
|
* CDATA, so we just look for the ending tag and need not care for
|
||||||
|
* any quote marks counting etc - YET, we are more tolerant and permit
|
||||||
|
* </script> stuff inside of the script if the whole <script> element
|
||||||
|
* contents is wrapped in a comment. See i.e. Mozilla bug 26857 for fun
|
||||||
|
* reading regarding this. */
|
||||||
|
for (; *end < eof; (*end)++) {
|
||||||
|
unsigned char *name;
|
||||||
|
int namelen;
|
||||||
|
|
||||||
|
if (in_comment) {
|
||||||
|
/* TODO: If we ever get some standards-quirk mode
|
||||||
|
* distinction, this should be disabled in the
|
||||||
|
* standards mode (and we should just look for CDATA
|
||||||
|
* end, which is "</"). --pasky */
|
||||||
|
if (eof - *end >= 3 && !strncmp(*end, "-->", 3)) {
|
||||||
|
/* Next iteration will jump passed the ending '>' */
|
||||||
|
(*end) += 2;
|
||||||
|
in_comment = 0;
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
/* XXX: Scan for another comment? That's admittelly
|
||||||
|
* already stretching things a little bit to an
|
||||||
|
* extreme ;-). */
|
||||||
|
}
|
||||||
|
|
||||||
|
if (**end != '<')
|
||||||
|
continue;
|
||||||
|
/* We want to land before the closing element, that's why we
|
||||||
|
* don't pass @end also as the appropriate parse_element()
|
||||||
|
* argument. */
|
||||||
|
if (parse_element(*end, eof, &name, &namelen, NULL, NULL))
|
||||||
|
continue;
|
||||||
|
if (strlcasecmp(name, namelen, "/script", 7))
|
||||||
|
continue;
|
||||||
|
/* We have won! */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (*end >= eof) {
|
||||||
|
/* Either the document is not completely loaded yet or it's
|
||||||
|
* broken. At any rate, run away screaming. */
|
||||||
|
*end = eof; /* Just for sanity. */
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (html_context->part->document && *html != '^') {
|
||||||
|
add_to_string_list(&html_context->part->document->onload_snippets,
|
||||||
|
html, *end - html);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -411,12 +590,20 @@ html_hr(struct html_context *html_context, unsigned char *a,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
html_table(struct html_context *html_context, unsigned char *a,
|
html_table(struct html_context *html_context, unsigned char *attr,
|
||||||
unsigned char *html, unsigned char *eof, unsigned char **end)
|
unsigned char *html, unsigned char *eof, unsigned char **end)
|
||||||
{
|
{
|
||||||
|
if (html_context->options->tables
|
||||||
|
&& html_context->table_level < HTML_MAX_TABLE_LEVEL) {
|
||||||
|
format_table(attr, html, eof, end, html_context);
|
||||||
|
ln_break(html_context, 2);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
par_format.leftmargin = par_format.rightmargin = html_context->margin;
|
par_format.leftmargin = par_format.rightmargin = html_context->margin;
|
||||||
par_format.align = ALIGN_LEFT;
|
par_format.align = ALIGN_LEFT;
|
||||||
html_linebrk(html_context, a, html, eof, end);
|
html_linebrk(html_context, attr, html, eof, end);
|
||||||
format.style.attr = 0;
|
format.style.attr = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
#include "document/html/parser/parse.h"
|
#include "document/html/parser/parse.h"
|
||||||
#include "document/html/parser/stack.h"
|
#include "document/html/parser/stack.h"
|
||||||
#include "document/html/parser.h"
|
#include "document/html/parser.h"
|
||||||
#include "document/html/tables.h"
|
|
||||||
#include "document/options.h"
|
#include "document/options.h"
|
||||||
#include "intl/charsets.h"
|
#include "intl/charsets.h"
|
||||||
#include "util/conv.h"
|
#include "util/conv.h"
|
||||||
@ -782,14 +781,6 @@ start_element(struct element_info *ei,
|
|||||||
restore_format = html_is_preformatted();
|
restore_format = html_is_preformatted();
|
||||||
old_format = par_format;
|
old_format = par_format;
|
||||||
|
|
||||||
if (ei->func == html_table && html_context->options->tables
|
|
||||||
&& html_context->table_level < HTML_MAX_TABLE_LEVEL) {
|
|
||||||
ELEMENT_RENDER_PROLOGUE
|
|
||||||
format_table(attr, html, eof, &html, html_context);
|
|
||||||
ln_break(html_context, 2);
|
|
||||||
return html;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Support for <meta refresh="..."> inside <body>. (bug 700) */
|
/* Support for <meta refresh="..."> inside <body>. (bug 700) */
|
||||||
if (ei->func == html_meta && html_context->was_body) {
|
if (ei->func == html_meta && html_context->was_body) {
|
||||||
html_handle_body_meta(html_context, name - 1, eof);
|
html_handle_body_meta(html_context, name - 1, eof);
|
||||||
|
@ -155,8 +155,10 @@ extern char *__builtin_stpcpy(char *dest, const char *src);
|
|||||||
extern void *__builtin_mempcpy(void *dest, const void *src, size_t n);
|
extern void *__builtin_mempcpy(void *dest, const void *src, size_t n);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if 0
|
||||||
#ifndef __builtin_va_copy
|
#ifndef __builtin_va_copy
|
||||||
#define __builtin_va_copy(dest, src) do { dest = src; } while (0)
|
#define __builtin_va_copy(dest, src) do { dest = src; } while (0)
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user