mirror of
https://github.com/rkd77/elinks.git
synced 2024-11-04 08:17:17 -05:00
Bug 784: Add html_context->doc_cp and parse attributes with it.
options->cp is still used for this in seven places where html_context is not easily available. Those should eventually be corrected too, but I'm checking this change in already because it's better than what we had before.
This commit is contained in:
parent
483386a6e5
commit
0b10539d10
@ -186,7 +186,7 @@ examine_element(struct html_context *html_context, struct css_selector *base,
|
|||||||
process_found_selector(selector, CST_PSEUDO, base);
|
process_found_selector(selector, CST_PSEUDO, base);
|
||||||
}
|
}
|
||||||
|
|
||||||
code = get_attr_val(element->options, "class", html_context->options->cp);
|
code = get_attr_val(element->options, "class", html_context->doc_cp);
|
||||||
if (code && seltype <= CST_CLASS) {
|
if (code && seltype <= CST_CLASS) {
|
||||||
unsigned char *class = code;
|
unsigned char *class = code;
|
||||||
|
|
||||||
@ -203,7 +203,7 @@ examine_element(struct html_context *html_context, struct css_selector *base,
|
|||||||
}
|
}
|
||||||
mem_free_if(code);
|
mem_free_if(code);
|
||||||
|
|
||||||
code = get_attr_val(element->options, "id", html_context->options->cp);
|
code = get_attr_val(element->options, "id", html_context->doc_cp);
|
||||||
if (code && seltype <= CST_ID) {
|
if (code && seltype <= CST_ID) {
|
||||||
selector = find_css_selector(selectors, CST_ID, rel, code, -1);
|
selector = find_css_selector(selectors, CST_ID, rel, code, -1);
|
||||||
process_found_selector(selector, CST_ID, base);
|
process_found_selector(selector, CST_ID, base);
|
||||||
@ -240,7 +240,7 @@ get_css_selector_for_element(struct html_context *html_context,
|
|||||||
DBG("Element %.*s applied.", element->namelen, element->name);
|
DBG("Element %.*s applied.", element->namelen, element->name);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
code = get_attr_val(element->options, "style", html_context->options->cp);
|
code = get_attr_val(element->options, "style", html_context->doc_cp);
|
||||||
if (code) {
|
if (code) {
|
||||||
struct css_selector *stylesel;
|
struct css_selector *stylesel;
|
||||||
struct scanner scanner;
|
struct scanner scanner;
|
||||||
|
@ -51,6 +51,10 @@ struct html_context {
|
|||||||
|
|
||||||
struct document_options *options;
|
struct document_options *options;
|
||||||
|
|
||||||
|
/* doc_cp is the charset of the document, i.e. part->document->cp.
|
||||||
|
* It is copied here because part->document is NULL sometimes. */
|
||||||
|
int doc_cp;
|
||||||
|
|
||||||
/* For:
|
/* For:
|
||||||
* html/parser/parse.c
|
* html/parser/parse.c
|
||||||
* html/parser/stack.c
|
* html/parser/stack.c
|
||||||
|
@ -57,7 +57,7 @@ get_color(struct html_context *html_context, unsigned char *a,
|
|||||||
if (!use_document_fg_colors(html_context->options))
|
if (!use_document_fg_colors(html_context->options))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
at = get_attr_val(a, c, html_context->options->cp);
|
at = get_attr_val(a, c, html_context->doc_cp);
|
||||||
if (!at) return -1;
|
if (!at) return -1;
|
||||||
|
|
||||||
r = decode_color(at, strlen(at), rgb);
|
r = decode_color(at, strlen(at), rgb);
|
||||||
@ -78,6 +78,8 @@ get_bgcolor(struct html_context *html_context, unsigned char *a, color_T *rgb)
|
|||||||
unsigned char *
|
unsigned char *
|
||||||
get_target(struct document_options *options, unsigned char *a)
|
get_target(struct document_options *options, unsigned char *a)
|
||||||
{
|
{
|
||||||
|
/* FIXME (bug 784): options->cp is the terminal charset;
|
||||||
|
* should use the document charset instead. */
|
||||||
unsigned char *v = get_attr_val(a, "target", options->cp);
|
unsigned char *v = get_attr_val(a, "target", options->cp);
|
||||||
|
|
||||||
if (!v) return NULL;
|
if (!v) return NULL;
|
||||||
@ -154,7 +156,7 @@ set_fragment_identifier(struct html_context *html_context,
|
|||||||
{
|
{
|
||||||
unsigned char *id_attr;
|
unsigned char *id_attr;
|
||||||
|
|
||||||
id_attr = get_attr_val(attr_name, attr, html_context->options->cp);
|
id_attr = get_attr_val(attr_name, attr, html_context->doc_cp);
|
||||||
|
|
||||||
if (id_attr) {
|
if (id_attr) {
|
||||||
html_context->special_f(html_context, SP_TAG, id_attr);
|
html_context->special_f(html_context, SP_TAG, id_attr);
|
||||||
@ -235,7 +237,7 @@ html_focusable(struct html_context *html_context, unsigned char *a)
|
|||||||
if (!a) return;
|
if (!a) return;
|
||||||
|
|
||||||
options = html_context->options;
|
options = html_context->options;
|
||||||
cp = options->cp;
|
cp = html_context->doc_cp;
|
||||||
|
|
||||||
accesskey = get_attr_val(a, "accesskey", cp);
|
accesskey = get_attr_val(a, "accesskey", cp);
|
||||||
if (accesskey) {
|
if (accesskey) {
|
||||||
@ -243,7 +245,7 @@ html_focusable(struct html_context *html_context, unsigned char *a)
|
|||||||
mem_free(accesskey);
|
mem_free(accesskey);
|
||||||
}
|
}
|
||||||
|
|
||||||
tabindex = get_num(a, "tabindex", options->cp);
|
tabindex = get_num(a, "tabindex", html_context->doc_cp);
|
||||||
if (0 < tabindex && tabindex < 32767) {
|
if (0 < tabindex && tabindex < 32767) {
|
||||||
format.tabindex = (tabindex & 0x7fff) << 16;
|
format.tabindex = (tabindex & 0x7fff) << 16;
|
||||||
}
|
}
|
||||||
@ -450,6 +452,8 @@ look_for_map(unsigned char **pos, unsigned char *eof, struct uri *uri,
|
|||||||
if (strlcasecmp(name, namelen, "MAP", 3)) return 1;
|
if (strlcasecmp(name, namelen, "MAP", 3)) return 1;
|
||||||
|
|
||||||
if (uri && uri->fragment) {
|
if (uri && uri->fragment) {
|
||||||
|
/* FIXME (bug 784): options->cp is the terminal charset;
|
||||||
|
* should use the document charset instead. */
|
||||||
al = get_attr_val(attr, "name", options->cp);
|
al = get_attr_val(attr, "name", options->cp);
|
||||||
if (!al) return 1;
|
if (!al) return 1;
|
||||||
|
|
||||||
@ -548,6 +552,8 @@ look_for_link(unsigned char **pos, unsigned char *eof, struct menu_item **menu,
|
|||||||
if (*pos >= eof) return 0;
|
if (*pos >= eof) return 0;
|
||||||
|
|
||||||
} else if (!strlcasecmp(name, namelen, "AREA", 4)) {
|
} else if (!strlcasecmp(name, namelen, "AREA", 4)) {
|
||||||
|
/* FIXME (bug 784): options->cp is the terminal charset;
|
||||||
|
* should use the document charset instead. */
|
||||||
unsigned char *alt = get_attr_val(attr, "alt", options->cp);
|
unsigned char *alt = get_attr_val(attr, "alt", options->cp);
|
||||||
|
|
||||||
if (alt) {
|
if (alt) {
|
||||||
@ -582,6 +588,8 @@ look_for_link(unsigned char **pos, unsigned char *eof, struct menu_item **menu,
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* FIXME (bug 784): options->cp is the terminal charset;
|
||||||
|
* should use the document charset instead. */
|
||||||
href = get_url_val(attr, "href", options->cp);
|
href = get_url_val(attr, "href", options->cp);
|
||||||
if (!href) {
|
if (!href) {
|
||||||
mem_free_if(label);
|
mem_free_if(label);
|
||||||
@ -741,6 +749,9 @@ done_html_parser_state(struct html_context *html_context,
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* This function does not set html_context.doc_cp = document.cp,
|
||||||
|
* because it does not know the document, and because the codepage has
|
||||||
|
* not even been decided when it is called. */
|
||||||
struct html_context *
|
struct html_context *
|
||||||
init_html_parser(struct uri *uri, struct document_options *options,
|
init_html_parser(struct uri *uri, struct document_options *options,
|
||||||
unsigned char *start, unsigned char *end,
|
unsigned char *start, unsigned char *end,
|
||||||
|
@ -50,13 +50,13 @@ html_form(struct html_context *html_context, unsigned char *a,
|
|||||||
form->method = FORM_METHOD_GET;
|
form->method = FORM_METHOD_GET;
|
||||||
form->form_num = a - html_context->startf;
|
form->form_num = a - html_context->startf;
|
||||||
|
|
||||||
al = get_attr_val(a, "method", html_context->options->cp);
|
al = get_attr_val(a, "method", html_context->doc_cp);
|
||||||
if (al) {
|
if (al) {
|
||||||
if (!strcasecmp(al, "post")) {
|
if (!strcasecmp(al, "post")) {
|
||||||
unsigned char *enctype;
|
unsigned char *enctype;
|
||||||
|
|
||||||
enctype = get_attr_val(a, "enctype",
|
enctype = get_attr_val(a, "enctype",
|
||||||
html_context->options->cp);
|
html_context->doc_cp);
|
||||||
|
|
||||||
form->method = FORM_METHOD_POST;
|
form->method = FORM_METHOD_POST;
|
||||||
if (enctype) {
|
if (enctype) {
|
||||||
@ -69,11 +69,11 @@ html_form(struct html_context *html_context, unsigned char *a,
|
|||||||
}
|
}
|
||||||
mem_free(al);
|
mem_free(al);
|
||||||
}
|
}
|
||||||
form->onsubmit = get_attr_val(a, "onsubmit", html_context->options->cp);
|
form->onsubmit = get_attr_val(a, "onsubmit", html_context->doc_cp);
|
||||||
al = get_attr_val(a, "name", html_context->options->cp);
|
al = get_attr_val(a, "name", html_context->doc_cp);
|
||||||
if (al) form->name = al;
|
if (al) form->name = al;
|
||||||
|
|
||||||
al = get_attr_val(a, "action", html_context->options->cp);
|
al = get_attr_val(a, "action", html_context->doc_cp);
|
||||||
/* The HTML specification at
|
/* The HTML specification at
|
||||||
* http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.3 states
|
* http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.3 states
|
||||||
* that the behavior of an empty action attribute should be undefined.
|
* that the behavior of an empty action attribute should be undefined.
|
||||||
@ -114,10 +114,10 @@ html_form(struct html_context *html_context, unsigned char *a,
|
|||||||
static int
|
static int
|
||||||
get_form_mode(struct html_context *html_context, unsigned char *attr)
|
get_form_mode(struct html_context *html_context, unsigned char *attr)
|
||||||
{
|
{
|
||||||
if (has_attr(attr, "disabled", html_context->options->cp))
|
if (has_attr(attr, "disabled", html_context->doc_cp))
|
||||||
return FORM_MODE_DISABLED;
|
return FORM_MODE_DISABLED;
|
||||||
|
|
||||||
if (has_attr(attr, "readonly", html_context->options->cp))
|
if (has_attr(attr, "readonly", html_context->doc_cp))
|
||||||
return FORM_MODE_READONLY;
|
return FORM_MODE_READONLY;
|
||||||
|
|
||||||
return FORM_MODE_NORMAL;
|
return FORM_MODE_NORMAL;
|
||||||
@ -146,8 +146,7 @@ html_button(struct html_context *html_context, unsigned char *a,
|
|||||||
unsigned char *al;
|
unsigned char *al;
|
||||||
struct form_control *fc;
|
struct form_control *fc;
|
||||||
enum form_type type = FC_SUBMIT;
|
enum form_type type = FC_SUBMIT;
|
||||||
int cp = (html_context->part && html_context->part->document) ?
|
int cp = html_context->doc_cp;
|
||||||
html_context->part->document->cp : html_context->options->cp;
|
|
||||||
|
|
||||||
html_focusable(html_context, a);
|
html_focusable(html_context, a);
|
||||||
|
|
||||||
@ -197,7 +196,7 @@ html_input_format(struct html_context *html_context, unsigned char *a,
|
|||||||
html_focusable(html_context, a);
|
html_focusable(html_context, a);
|
||||||
format.form = fc;
|
format.form = fc;
|
||||||
if (format.title) mem_free(format.title);
|
if (format.title) mem_free(format.title);
|
||||||
format.title = get_attr_val(a, "title", html_context->options->cp);
|
format.title = get_attr_val(a, "title", html_context->doc_cp);
|
||||||
switch (fc->type) {
|
switch (fc->type) {
|
||||||
case FC_TEXT:
|
case FC_TEXT:
|
||||||
case FC_PASSWORD:
|
case FC_PASSWORD:
|
||||||
@ -223,10 +222,10 @@ html_input_format(struct html_context *html_context, unsigned char *a,
|
|||||||
unsigned char *al;
|
unsigned char *al;
|
||||||
|
|
||||||
mem_free_set(&format.image, NULL);
|
mem_free_set(&format.image, NULL);
|
||||||
al = get_url_val(a, "src", html_context->options->cp);
|
al = get_url_val(a, "src", html_context->doc_cp);
|
||||||
if (!al)
|
if (!al)
|
||||||
al = get_url_val(a, "dynsrc",
|
al = get_url_val(a, "dynsrc",
|
||||||
html_context->options->cp);
|
html_context->doc_cp);
|
||||||
if (al) {
|
if (al) {
|
||||||
format.image = join_urls(html_context->base_href, al);
|
format.image = join_urls(html_context->base_href, al);
|
||||||
mem_free(al);
|
mem_free(al);
|
||||||
@ -267,8 +266,7 @@ html_input(struct html_context *html_context, unsigned char *a,
|
|||||||
{
|
{
|
||||||
unsigned char *al;
|
unsigned char *al;
|
||||||
struct form_control *fc;
|
struct form_control *fc;
|
||||||
int cp = (html_context->part && html_context->part->document) ?
|
int cp = html_context->doc_cp;
|
||||||
html_context->part->document->cp : html_context->options->cp;
|
|
||||||
|
|
||||||
fc = init_form_control(FC_TEXT, a, html_context);
|
fc = init_form_control(FC_TEXT, a, html_context);
|
||||||
if (!fc) return;
|
if (!fc) return;
|
||||||
@ -421,18 +419,18 @@ abort:
|
|||||||
if (!closing_tag) {
|
if (!closing_tag) {
|
||||||
unsigned char *value, *label;
|
unsigned char *value, *label;
|
||||||
|
|
||||||
if (has_attr(t_attr, "disabled", html_context->options->cp))
|
if (has_attr(t_attr, "disabled", html_context->doc_cp))
|
||||||
goto see;
|
goto see;
|
||||||
if (preselect == -1
|
if (preselect == -1
|
||||||
&& has_attr(t_attr, "selected", html_context->options->cp))
|
&& has_attr(t_attr, "selected", html_context->doc_cp))
|
||||||
preselect = order;
|
preselect = order;
|
||||||
value = get_attr_val(t_attr, "value", html_context->options->cp);
|
value = get_attr_val(t_attr, "value", html_context->doc_cp);
|
||||||
|
|
||||||
if (!mem_align_alloc(&values, order, order + 1, 0xFF))
|
if (!mem_align_alloc(&values, order, order + 1, 0xFF))
|
||||||
goto abort;
|
goto abort;
|
||||||
|
|
||||||
values[order++] = value;
|
values[order++] = value;
|
||||||
label = get_attr_val(t_attr, "label", html_context->options->cp);
|
label = get_attr_val(t_attr, "label", html_context->doc_cp);
|
||||||
if (label) new_menu_item(&lnk_menu, label, order - 1, 0);
|
if (label) new_menu_item(&lnk_menu, label, order - 1, 0);
|
||||||
if (!value || !label) {
|
if (!value || !label) {
|
||||||
init_string(&lbl);
|
init_string(&lbl);
|
||||||
@ -452,7 +450,7 @@ abort:
|
|||||||
if (!closing_tag) {
|
if (!closing_tag) {
|
||||||
unsigned char *label;
|
unsigned char *label;
|
||||||
|
|
||||||
label = get_attr_val(t_attr, "label", html_context->options->cp);
|
label = get_attr_val(t_attr, "label", html_context->doc_cp);
|
||||||
|
|
||||||
if (!label) {
|
if (!label) {
|
||||||
label = stracpy("");
|
label = stracpy("");
|
||||||
@ -479,9 +477,9 @@ end_parse:
|
|||||||
goto abort;
|
goto abort;
|
||||||
}
|
}
|
||||||
|
|
||||||
fc->id = get_attr_val(attr, "id", html_context->options->cp);
|
fc->id = get_attr_val(attr, "id", html_context->doc_cp);
|
||||||
fc->name = get_attr_val(attr, "name", html_context->options->cp);
|
fc->name = get_attr_val(attr, "name", html_context->doc_cp);
|
||||||
fc->onchange = get_attr_val(attr, "onchange", html_context->options->cp);
|
fc->onchange = get_attr_val(attr, "onchange", html_context->doc_cp);
|
||||||
fc->default_state = preselect < 0 ? 0 : preselect;
|
fc->default_state = preselect < 0 ? 0 : preselect;
|
||||||
fc->default_value = order ? stracpy(values[fc->default_state]) : stracpy("");
|
fc->default_value = order ? stracpy(values[fc->default_state]) : stracpy("");
|
||||||
fc->nvalues = order;
|
fc->nvalues = order;
|
||||||
@ -521,13 +519,13 @@ do_html_select_multiple(struct html_context *html_context, unsigned char *a,
|
|||||||
unsigned char *html, unsigned char *eof,
|
unsigned char *html, unsigned char *eof,
|
||||||
unsigned char **end)
|
unsigned char **end)
|
||||||
{
|
{
|
||||||
unsigned char *al = get_attr_val(a, "name", html_context->options->cp);
|
unsigned char *al = get_attr_val(a, "name", html_context->doc_cp);
|
||||||
|
|
||||||
if (!al) return;
|
if (!al) return;
|
||||||
html_focusable(html_context, a);
|
html_focusable(html_context, a);
|
||||||
html_top->type = ELEMENT_DONT_KILL;
|
html_top->type = ELEMENT_DONT_KILL;
|
||||||
mem_free_set(&format.select, al);
|
mem_free_set(&format.select, al);
|
||||||
format.select_disabled = has_attr(a, "disabled", html_context->options->cp)
|
format.select_disabled = has_attr(a, "disabled", html_context->doc_cp)
|
||||||
? FORM_MODE_DISABLED
|
? FORM_MODE_DISABLED
|
||||||
: FORM_MODE_NORMAL;
|
: FORM_MODE_NORMAL;
|
||||||
}
|
}
|
||||||
@ -536,7 +534,7 @@ void
|
|||||||
html_select(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)
|
||||||
{
|
{
|
||||||
if (has_attr(a, "multiple", html_context->options->cp))
|
if (has_attr(a, "multiple", html_context->doc_cp))
|
||||||
do_html_select_multiple(html_context, a, html, eof, end);
|
do_html_select_multiple(html_context, a, html, eof, end);
|
||||||
else
|
else
|
||||||
do_html_select(a, html, eof, end, html_context);
|
do_html_select(a, html, eof, end, html_context);
|
||||||
@ -552,7 +550,7 @@ html_option(struct html_context *html_context, unsigned char *a,
|
|||||||
|
|
||||||
if (!format.select) return;
|
if (!format.select) return;
|
||||||
|
|
||||||
val = get_attr_val(a, "value", html_context->options->cp);
|
val = get_attr_val(a, "value", html_context->doc_cp);
|
||||||
if (!val) {
|
if (!val) {
|
||||||
struct string str;
|
struct string str;
|
||||||
unsigned char *p, *r;
|
unsigned char *p, *r;
|
||||||
@ -603,11 +601,11 @@ end_parse:
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fc->id = get_attr_val(a, "id", html_context->options->cp);
|
fc->id = get_attr_val(a, "id", html_context->doc_cp);
|
||||||
fc->name = null_or_stracpy(format.select);
|
fc->name = null_or_stracpy(format.select);
|
||||||
fc->default_value = val;
|
fc->default_value = val;
|
||||||
fc->default_state = has_attr(a, "selected", html_context->options->cp);
|
fc->default_state = has_attr(a, "selected", html_context->doc_cp);
|
||||||
fc->mode = has_attr(a, "disabled", html_context->options->cp)
|
fc->mode = has_attr(a, "disabled", html_context->doc_cp)
|
||||||
? FORM_MODE_DISABLED
|
? FORM_MODE_DISABLED
|
||||||
: format.select_disabled;
|
: format.select_disabled;
|
||||||
|
|
||||||
@ -649,8 +647,8 @@ pp:
|
|||||||
fc = init_form_control(FC_TEXTAREA, attr, html_context);
|
fc = init_form_control(FC_TEXTAREA, attr, html_context);
|
||||||
if (!fc) return;
|
if (!fc) return;
|
||||||
|
|
||||||
fc->id = get_attr_val(attr, "id", html_context->options->cp);
|
fc->id = get_attr_val(attr, "id", html_context->doc_cp);
|
||||||
fc->name = get_attr_val(attr, "name", html_context->options->cp);
|
fc->name = get_attr_val(attr, "name", html_context->doc_cp);
|
||||||
fc->default_value = memacpy(html, p - html);
|
fc->default_value = memacpy(html, p - html);
|
||||||
for (p = fc->default_value; p && p[0]; p++) {
|
for (p = fc->default_value; p && p[0]; p++) {
|
||||||
/* FIXME: We don't cope well with entities here. Bugzilla uses
|
/* FIXME: We don't cope well with entities here. Bugzilla uses
|
||||||
@ -667,7 +665,7 @@ pp:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cols = get_num(attr, "cols", html_context->options->cp);
|
cols = get_num(attr, "cols", html_context->doc_cp);
|
||||||
if (cols <= 0)
|
if (cols <= 0)
|
||||||
cols = html_context->options->default_form_input_size;
|
cols = html_context->options->default_form_input_size;
|
||||||
cols++; /* Add 1 column, other browsers may have different
|
cols++; /* Add 1 column, other browsers may have different
|
||||||
@ -676,14 +674,14 @@ pp:
|
|||||||
cols = html_context->options->box.width;
|
cols = html_context->options->box.width;
|
||||||
fc->cols = cols;
|
fc->cols = cols;
|
||||||
|
|
||||||
rows = get_num(attr, "rows", html_context->options->cp);
|
rows = get_num(attr, "rows", html_context->doc_cp);
|
||||||
if (rows <= 0) rows = 1;
|
if (rows <= 0) rows = 1;
|
||||||
if (rows > html_context->options->box.height)
|
if (rows > html_context->options->box.height)
|
||||||
rows = html_context->options->box.height;
|
rows = html_context->options->box.height;
|
||||||
fc->rows = rows;
|
fc->rows = rows;
|
||||||
html_context->options->needs_height = 1;
|
html_context->options->needs_height = 1;
|
||||||
|
|
||||||
wrap_attr = get_attr_val(attr, "wrap", html_context->options->cp);
|
wrap_attr = get_attr_val(attr, "wrap", html_context->doc_cp);
|
||||||
if (wrap_attr) {
|
if (wrap_attr) {
|
||||||
if (!strcasecmp(wrap_attr, "hard")
|
if (!strcasecmp(wrap_attr, "hard")
|
||||||
|| !strcasecmp(wrap_attr, "physical")) {
|
|| !strcasecmp(wrap_attr, "physical")) {
|
||||||
@ -697,14 +695,14 @@ pp:
|
|||||||
}
|
}
|
||||||
mem_free(wrap_attr);
|
mem_free(wrap_attr);
|
||||||
|
|
||||||
} else if (has_attr(attr, "nowrap", html_context->options->cp)) {
|
} else if (has_attr(attr, "nowrap", html_context->doc_cp)) {
|
||||||
fc->wrap = FORM_WRAP_NONE;
|
fc->wrap = FORM_WRAP_NONE;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
fc->wrap = FORM_WRAP_SOFT;
|
fc->wrap = FORM_WRAP_SOFT;
|
||||||
}
|
}
|
||||||
|
|
||||||
fc->maxlength = get_num(attr, "maxlength", html_context->options->cp);
|
fc->maxlength = get_num(attr, "maxlength", html_context->doc_cp);
|
||||||
if (fc->maxlength == -1) fc->maxlength = INT_MAX;
|
if (fc->maxlength == -1) fc->maxlength = INT_MAX;
|
||||||
|
|
||||||
if (rows > 1) ln_break(html_context, 1);
|
if (rows > 1) ln_break(html_context, 1);
|
||||||
|
@ -136,7 +136,7 @@ void
|
|||||||
html_font(struct html_context *html_context, unsigned char *a,
|
html_font(struct html_context *html_context, unsigned char *a,
|
||||||
unsigned char *xxx3, unsigned char *xxx4, unsigned char **xxx5)
|
unsigned char *xxx3, unsigned char *xxx4, unsigned char **xxx5)
|
||||||
{
|
{
|
||||||
unsigned char *al = get_attr_val(a, "size", html_context->options->cp);
|
unsigned char *al = get_attr_val(a, "size", html_context->doc_cp);
|
||||||
|
|
||||||
if (al) {
|
if (al) {
|
||||||
int p = 0;
|
int p = 0;
|
||||||
@ -223,7 +223,7 @@ html_script(struct html_context *html_context, unsigned char *a,
|
|||||||
/* Ref:
|
/* Ref:
|
||||||
* http://www.ietf.org/internet-drafts/draft-hoehrmann-script-types-03.txt
|
* http://www.ietf.org/internet-drafts/draft-hoehrmann-script-types-03.txt
|
||||||
*/
|
*/
|
||||||
type = get_attr_val(a, "type", html_context->options->cp);
|
type = get_attr_val(a, "type", html_context->doc_cp);
|
||||||
if (type) {
|
if (type) {
|
||||||
unsigned char *pos = type;
|
unsigned char *pos = type;
|
||||||
|
|
||||||
@ -265,7 +265,7 @@ not_processed:
|
|||||||
* language attribute can be JavaScript with optional version digits
|
* language attribute can be JavaScript with optional version digits
|
||||||
* postfixed (like: ``JavaScript1.1'').
|
* postfixed (like: ``JavaScript1.1'').
|
||||||
* That attribute is deprecated in favor of type by HTML 4.01 */
|
* That attribute is deprecated in favor of type by HTML 4.01 */
|
||||||
language = get_attr_val(a, "language", html_context->options->cp);
|
language = get_attr_val(a, "language", html_context->doc_cp);
|
||||||
if (language) {
|
if (language) {
|
||||||
int languagelen = strlen(language);
|
int languagelen = strlen(language);
|
||||||
|
|
||||||
@ -280,7 +280,7 @@ not_processed:
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (html_context->part->document
|
if (html_context->part->document
|
||||||
&& (src = get_attr_val(a, "src", html_context->options->cp))) {
|
&& (src = get_attr_val(a, "src", html_context->doc_cp))) {
|
||||||
/* External reference. */
|
/* External reference. */
|
||||||
|
|
||||||
unsigned char *import_url;
|
unsigned char *import_url;
|
||||||
@ -479,7 +479,7 @@ void
|
|||||||
html_linebrk(struct html_context *html_context, unsigned char *a,
|
html_linebrk(struct html_context *html_context, unsigned char *a,
|
||||||
unsigned char *xxx3, unsigned char *xxx4, unsigned char **xxx5)
|
unsigned char *xxx3, unsigned char *xxx4, unsigned char **xxx5)
|
||||||
{
|
{
|
||||||
unsigned char *al = get_attr_val(a, "align", html_context->options->cp);
|
unsigned char *al = get_attr_val(a, "align", html_context->doc_cp);
|
||||||
|
|
||||||
if (al) {
|
if (al) {
|
||||||
if (!strcasecmp(al, "left")) par_format.align = ALIGN_LEFT;
|
if (!strcasecmp(al, "left")) par_format.align = ALIGN_LEFT;
|
||||||
@ -632,7 +632,7 @@ html_hr(struct html_context *html_context, unsigned char *a,
|
|||||||
{
|
{
|
||||||
int i/* = par_format.width - 10*/;
|
int i/* = par_format.width - 10*/;
|
||||||
unsigned char r = (unsigned char) BORDER_DHLINE;
|
unsigned char r = (unsigned char) BORDER_DHLINE;
|
||||||
int q = get_num(a, "size", html_context->options->cp);
|
int q = get_num(a, "size", html_context->doc_cp);
|
||||||
|
|
||||||
if (q >= 0 && q < 2) r = (unsigned char) BORDER_SHLINE;
|
if (q >= 0 && q < 2) r = (unsigned char) BORDER_SHLINE;
|
||||||
html_stack_dup(html_context, ELEMENT_KILLABLE);
|
html_stack_dup(html_context, ELEMENT_KILLABLE);
|
||||||
@ -714,7 +714,7 @@ html_base(struct html_context *html_context, unsigned char *a,
|
|||||||
{
|
{
|
||||||
unsigned char *al;
|
unsigned char *al;
|
||||||
|
|
||||||
al = get_url_val(a, "href", html_context->options->cp);
|
al = get_url_val(a, "href", html_context->doc_cp);
|
||||||
if (al) {
|
if (al) {
|
||||||
unsigned char *base = join_urls(html_context->base_href, al);
|
unsigned char *base = join_urls(html_context->base_href, al);
|
||||||
struct uri *uri = base ? get_uri(base, 0) : NULL;
|
struct uri *uri = base ? get_uri(base, 0) : NULL;
|
||||||
@ -743,7 +743,7 @@ html_ul(struct html_context *html_context, unsigned char *a,
|
|||||||
par_format.list_number = 0;
|
par_format.list_number = 0;
|
||||||
par_format.flags = P_STAR;
|
par_format.flags = P_STAR;
|
||||||
|
|
||||||
al = get_attr_val(a, "type", html_context->options->cp);
|
al = get_attr_val(a, "type", html_context->doc_cp);
|
||||||
if (al) {
|
if (al) {
|
||||||
if (!strcasecmp(al, "disc") || !strcasecmp(al, "circle"))
|
if (!strcasecmp(al, "disc") || !strcasecmp(al, "circle"))
|
||||||
par_format.flags = P_O;
|
par_format.flags = P_O;
|
||||||
@ -767,12 +767,12 @@ html_ol(struct html_context *html_context, unsigned char *a,
|
|||||||
int st;
|
int st;
|
||||||
|
|
||||||
par_format.list_level++;
|
par_format.list_level++;
|
||||||
st = get_num(a, "start", html_context->options->cp);
|
st = get_num(a, "start", html_context->doc_cp);
|
||||||
if (st == -1) st = 1;
|
if (st == -1) st = 1;
|
||||||
par_format.list_number = st;
|
par_format.list_number = st;
|
||||||
par_format.flags = P_NUMBER;
|
par_format.flags = P_NUMBER;
|
||||||
|
|
||||||
al = get_attr_val(a, "type", html_context->options->cp);
|
al = get_attr_val(a, "type", html_context->doc_cp);
|
||||||
if (al) {
|
if (al) {
|
||||||
if (*al && !al[1]) {
|
if (*al && !al[1]) {
|
||||||
if (*al == '1') par_format.flags = P_NUMBER;
|
if (*al == '1') par_format.flags = P_NUMBER;
|
||||||
@ -875,7 +875,7 @@ html_li(struct html_context *html_context, unsigned char *a,
|
|||||||
unsigned char n[32];
|
unsigned char n[32];
|
||||||
int nlen;
|
int nlen;
|
||||||
int t = par_format.flags & P_LISTMASK;
|
int t = par_format.flags & P_LISTMASK;
|
||||||
int s = get_num(a, "value", html_context->options->cp);
|
int s = get_num(a, "value", html_context->doc_cp);
|
||||||
|
|
||||||
if (s != -1) par_format.list_number = s;
|
if (s != -1) par_format.list_number = s;
|
||||||
|
|
||||||
@ -932,7 +932,7 @@ html_dl(struct html_context *html_context, unsigned char *a,
|
|||||||
unsigned char *xxx3, unsigned char *xxx4, unsigned char **xxx5)
|
unsigned char *xxx3, unsigned char *xxx4, unsigned char **xxx5)
|
||||||
{
|
{
|
||||||
par_format.flags &= ~P_COMPACT;
|
par_format.flags &= ~P_COMPACT;
|
||||||
if (has_attr(a, "compact", html_context->options->cp))
|
if (has_attr(a, "compact", html_context->doc_cp))
|
||||||
par_format.flags |= P_COMPACT;
|
par_format.flags |= P_COMPACT;
|
||||||
if (par_format.list_level) par_format.leftmargin += 5;
|
if (par_format.list_level) par_format.leftmargin += 5;
|
||||||
par_format.list_level++;
|
par_format.list_level++;
|
||||||
@ -954,7 +954,7 @@ html_dt(struct html_context *html_context, unsigned char *a,
|
|||||||
par_format.align = ALIGN_LEFT;
|
par_format.align = ALIGN_LEFT;
|
||||||
par_format.leftmargin = par_format.dd_margin;
|
par_format.leftmargin = par_format.dd_margin;
|
||||||
if (!(par_format.flags & P_COMPACT)
|
if (!(par_format.flags & P_COMPACT)
|
||||||
&& !has_attr(a, "compact", html_context->options->cp))
|
&& !has_attr(a, "compact", html_context->doc_cp))
|
||||||
ln_break(html_context, 2);
|
ln_break(html_context, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -995,7 +995,7 @@ html_frame(struct html_context *html_context, unsigned char *a,
|
|||||||
{
|
{
|
||||||
unsigned char *name, *src, *url;
|
unsigned char *name, *src, *url;
|
||||||
|
|
||||||
src = get_url_val(a, "src", html_context->options->cp);
|
src = get_url_val(a, "src", html_context->doc_cp);
|
||||||
if (!src) {
|
if (!src) {
|
||||||
url = stracpy("about:blank");
|
url = stracpy("about:blank");
|
||||||
} else {
|
} else {
|
||||||
@ -1004,7 +1004,7 @@ html_frame(struct html_context *html_context, unsigned char *a,
|
|||||||
}
|
}
|
||||||
if (!url) return;
|
if (!url) return;
|
||||||
|
|
||||||
name = get_attr_val(a, "name", html_context->options->cp);
|
name = get_attr_val(a, "name", html_context->doc_cp);
|
||||||
if (!name) {
|
if (!name) {
|
||||||
name = stracpy(url);
|
name = stracpy(url);
|
||||||
} else if (!name[0]) {
|
} else if (!name[0]) {
|
||||||
@ -1048,13 +1048,13 @@ html_frameset(struct html_context *html_context, unsigned char *a,
|
|||||||
|| !html_context->special_f(html_context, SP_USED, NULL))
|
|| !html_context->special_f(html_context, SP_USED, NULL))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
cols = get_attr_val(a, "cols", html_context->options->cp);
|
cols = get_attr_val(a, "cols", html_context->doc_cp);
|
||||||
if (!cols) {
|
if (!cols) {
|
||||||
cols = stracpy("100%");
|
cols = stracpy("100%");
|
||||||
if (!cols) return;
|
if (!cols) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
rows = get_attr_val(a, "rows", html_context->options->cp);
|
rows = get_attr_val(a, "rows", html_context->doc_cp);
|
||||||
if (!rows) {
|
if (!rows) {
|
||||||
rows = stracpy("100%");
|
rows = stracpy("100%");
|
||||||
if (!rows) {
|
if (!rows) {
|
||||||
|
@ -45,7 +45,7 @@ html_a(struct html_context *html_context, unsigned char *a,
|
|||||||
{
|
{
|
||||||
unsigned char *href;
|
unsigned char *href;
|
||||||
|
|
||||||
href = get_url_val(a, "href", html_context->options->cp);
|
href = get_url_val(a, "href", html_context->doc_cp);
|
||||||
if (href) {
|
if (href) {
|
||||||
unsigned char *target;
|
unsigned char *target;
|
||||||
|
|
||||||
@ -84,7 +84,7 @@ html_a(struct html_context *html_context, unsigned char *a,
|
|||||||
}
|
}
|
||||||
|
|
||||||
mem_free_set(&format.title,
|
mem_free_set(&format.title,
|
||||||
get_attr_val(a, "title", html_context->options->cp));
|
get_attr_val(a, "title", html_context->doc_cp));
|
||||||
|
|
||||||
html_focusable(html_context, a);
|
html_focusable(html_context, a);
|
||||||
|
|
||||||
@ -215,8 +215,6 @@ html_img_do(unsigned char *a, unsigned char *object_src,
|
|||||||
unsigned char *usemap_attr;
|
unsigned char *usemap_attr;
|
||||||
struct document_options *options = html_context->options;
|
struct document_options *options = html_context->options;
|
||||||
int display_style = options->image_link.display_style;
|
int display_style = options->image_link.display_style;
|
||||||
int cp = (html_context->part && html_context->part->document) ?
|
|
||||||
html_context->part->document->cp : html_context->options->cp;
|
|
||||||
|
|
||||||
/* Note about display_style:
|
/* Note about display_style:
|
||||||
* 0 means always display IMG
|
* 0 means always display IMG
|
||||||
@ -224,7 +222,7 @@ html_img_do(unsigned char *a, unsigned char *object_src,
|
|||||||
* 2 means display alt/title attribute if possible, IMG if not
|
* 2 means display alt/title attribute if possible, IMG if not
|
||||||
* 3 means display alt/title attribute if possible, filename if not */
|
* 3 means display alt/title attribute if possible, filename if not */
|
||||||
|
|
||||||
usemap_attr = get_attr_val(a, "usemap", options->cp);
|
usemap_attr = get_attr_val(a, "usemap", html_context->doc_cp);
|
||||||
if (usemap_attr) {
|
if (usemap_attr) {
|
||||||
unsigned char *joined_urls = join_urls(html_context->base_href,
|
unsigned char *joined_urls = join_urls(html_context->base_href,
|
||||||
usemap_attr);
|
usemap_attr);
|
||||||
@ -245,13 +243,13 @@ html_img_do(unsigned char *a, unsigned char *object_src,
|
|||||||
}
|
}
|
||||||
|
|
||||||
ismap = format.link
|
ismap = format.link
|
||||||
&& has_attr(a, "ismap", options->cp)
|
&& has_attr(a, "ismap", html_context->doc_cp)
|
||||||
&& !usemap;
|
&& !usemap;
|
||||||
|
|
||||||
if (display_style == 2 || display_style == 3) {
|
if (display_style == 2 || display_style == 3) {
|
||||||
label = get_attr_val(a, "alt", cp);
|
label = get_attr_val(a, "alt", html_context->doc_cp);
|
||||||
if (!label)
|
if (!label)
|
||||||
label = get_attr_val(a, "title", options->cp);
|
label = get_attr_val(a, "title", html_context->doc_cp);
|
||||||
|
|
||||||
/* Little hack to preserve rendering of [ ], in directories listing,
|
/* Little hack to preserve rendering of [ ], in directories listing,
|
||||||
* but we still want to drop extra spaces in alt or title attribute
|
* but we still want to drop extra spaces in alt or title attribute
|
||||||
@ -260,8 +258,8 @@ html_img_do(unsigned char *a, unsigned char *object_src,
|
|||||||
}
|
}
|
||||||
|
|
||||||
src = null_or_stracpy(object_src);
|
src = null_or_stracpy(object_src);
|
||||||
if (!src) src = get_url_val(a, "src", options->cp);
|
if (!src) src = get_url_val(a, "src", html_context->doc_cp);
|
||||||
if (!src) src = get_url_val(a, "dynsrc", options->cp);
|
if (!src) src = get_url_val(a, "dynsrc", html_context->doc_cp);
|
||||||
|
|
||||||
/* If we have no label yet (no title or alt), so
|
/* If we have no label yet (no title or alt), so
|
||||||
* just use default ones, or image filename. */
|
* just use default ones, or image filename. */
|
||||||
@ -322,7 +320,7 @@ html_img_do(unsigned char *a, unsigned char *object_src,
|
|||||||
format.image = join_urls(html_context->base_href, src);
|
format.image = join_urls(html_context->base_href, src);
|
||||||
}
|
}
|
||||||
|
|
||||||
format.title = get_attr_val(a, "title", options->cp);
|
format.title = get_attr_val(a, "title", html_context->doc_cp);
|
||||||
|
|
||||||
if (ismap) {
|
if (ismap) {
|
||||||
unsigned char *new_link;
|
unsigned char *new_link;
|
||||||
@ -382,10 +380,10 @@ html_applet(struct html_context *html_context, unsigned char *a,
|
|||||||
{
|
{
|
||||||
unsigned char *code, *alt;
|
unsigned char *code, *alt;
|
||||||
|
|
||||||
code = get_url_val(a, "code", html_context->options->cp);
|
code = get_url_val(a, "code", html_context->doc_cp);
|
||||||
if (!code) return;
|
if (!code) return;
|
||||||
|
|
||||||
alt = get_attr_val(a, "alt", html_context->options->cp);
|
alt = get_attr_val(a, "alt", html_context->doc_cp);
|
||||||
|
|
||||||
html_focusable(html_context, a);
|
html_focusable(html_context, a);
|
||||||
|
|
||||||
@ -408,11 +406,11 @@ html_iframe_do(unsigned char *a, unsigned char *object_src,
|
|||||||
unsigned char *name, *url = NULL;
|
unsigned char *name, *url = NULL;
|
||||||
|
|
||||||
url = null_or_stracpy(object_src);
|
url = null_or_stracpy(object_src);
|
||||||
if (!url) url = get_url_val(a, "src", html_context->options->cp);
|
if (!url) url = get_url_val(a, "src", html_context->doc_cp);
|
||||||
if (!url) return;
|
if (!url) return;
|
||||||
|
|
||||||
name = get_attr_val(a, "name", html_context->options->cp);
|
name = get_attr_val(a, "name", html_context->doc_cp);
|
||||||
if (!name) name = get_attr_val(a, "id", html_context->options->cp);
|
if (!name) name = get_attr_val(a, "id", html_context->doc_cp);
|
||||||
if (!name) name = stracpy("");
|
if (!name) name = stracpy("");
|
||||||
if (!name) {
|
if (!name) {
|
||||||
mem_free(url);
|
mem_free(url);
|
||||||
@ -450,11 +448,11 @@ html_object(struct html_context *html_context, unsigned char *a,
|
|||||||
* this, which is anyway in the spirit of <object> element, unifying
|
* this, which is anyway in the spirit of <object> element, unifying
|
||||||
* <img> and <iframe> etc. */
|
* <img> and <iframe> etc. */
|
||||||
|
|
||||||
url = get_url_val(a, "data", html_context->options->cp);
|
url = get_url_val(a, "data", html_context->doc_cp);
|
||||||
if (!url) url = get_url_val(a, "codebase", html_context->options->cp);
|
if (!url) url = get_url_val(a, "codebase", html_context->doc_cp);
|
||||||
if (!url) return;
|
if (!url) return;
|
||||||
|
|
||||||
type = get_attr_val(a, "type", html_context->options->cp);
|
type = get_attr_val(a, "type", html_context->doc_cp);
|
||||||
if (!type) { mem_free(url); return; }
|
if (!type) { mem_free(url); return; }
|
||||||
|
|
||||||
if (!strncasecmp(type, "text/", 5)) {
|
if (!strncasecmp(type, "text/", 5)) {
|
||||||
@ -469,7 +467,7 @@ html_object(struct html_context *html_context, unsigned char *a,
|
|||||||
} else {
|
} else {
|
||||||
unsigned char *name;
|
unsigned char *name;
|
||||||
|
|
||||||
name = get_attr_val(a, "standby", html_context->options->cp);
|
name = get_attr_val(a, "standby", html_context->doc_cp);
|
||||||
|
|
||||||
html_focusable(html_context, a);
|
html_focusable(html_context, a);
|
||||||
|
|
||||||
@ -501,7 +499,7 @@ html_embed(struct html_context *html_context, unsigned char *a,
|
|||||||
* this, which is anyway in the spirit of <object> element, unifying
|
* this, which is anyway in the spirit of <object> element, unifying
|
||||||
* <img> and <iframe> etc. */
|
* <img> and <iframe> etc. */
|
||||||
|
|
||||||
object_src = get_url_val(a, "src", html_context->options->cp);
|
object_src = get_url_val(a, "src", html_context->doc_cp);
|
||||||
if (!object_src || !*object_src) {
|
if (!object_src || !*object_src) {
|
||||||
mem_free_set(&object_src, NULL);
|
mem_free_set(&object_src, NULL);
|
||||||
return;
|
return;
|
||||||
@ -730,20 +728,20 @@ html_link_parse(struct html_context *html_context, unsigned char *a,
|
|||||||
assert(a && link);
|
assert(a && link);
|
||||||
memset(link, 0, sizeof(*link));
|
memset(link, 0, sizeof(*link));
|
||||||
|
|
||||||
link->href = get_url_val(a, "href", html_context->options->cp);
|
link->href = get_url_val(a, "href", html_context->doc_cp);
|
||||||
if (!link->href) return 0;
|
if (!link->href) return 0;
|
||||||
|
|
||||||
link->lang = get_attr_val(a, "lang", html_context->options->cp);
|
link->lang = get_attr_val(a, "lang", html_context->doc_cp);
|
||||||
link->hreflang = get_attr_val(a, "hreflang", html_context->options->cp);
|
link->hreflang = get_attr_val(a, "hreflang", html_context->doc_cp);
|
||||||
link->title = get_attr_val(a, "title", html_context->options->cp);
|
link->title = get_attr_val(a, "title", html_context->doc_cp);
|
||||||
link->content_type = get_attr_val(a, "type", html_context->options->cp);
|
link->content_type = get_attr_val(a, "type", html_context->doc_cp);
|
||||||
link->media = get_attr_val(a, "media", html_context->options->cp);
|
link->media = get_attr_val(a, "media", html_context->doc_cp);
|
||||||
|
|
||||||
link->name = get_attr_val(a, "rel", html_context->options->cp);
|
link->name = get_attr_val(a, "rel", html_context->doc_cp);
|
||||||
if (link->name) {
|
if (link->name) {
|
||||||
link->direction = LD_REL;
|
link->direction = LD_REL;
|
||||||
} else {
|
} else {
|
||||||
link->name = get_attr_val(a, "rev", html_context->options->cp);
|
link->name = get_attr_val(a, "rev", html_context->doc_cp);
|
||||||
if (link->name) link->direction = LD_REV;
|
if (link->name) link->direction = LD_REV;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -273,7 +273,7 @@ int
|
|||||||
get_width(unsigned char *a, unsigned char *name, int limited,
|
get_width(unsigned char *a, unsigned char *name, int limited,
|
||||||
struct html_context *html_context)
|
struct html_context *html_context)
|
||||||
{
|
{
|
||||||
unsigned char *value = get_attr_val(a, name, html_context->options->cp);
|
unsigned char *value = get_attr_val(a, name, html_context->doc_cp);
|
||||||
unsigned char *str = value;
|
unsigned char *str = value;
|
||||||
unsigned char *end;
|
unsigned char *end;
|
||||||
int percentage = 0;
|
int percentage = 0;
|
||||||
@ -809,7 +809,7 @@ start_element(struct element_info *ei,
|
|||||||
{
|
{
|
||||||
#define ELEMENT_RENDER_PROLOGUE \
|
#define ELEMENT_RENDER_PROLOGUE \
|
||||||
ln_break(html_context, ei->linebreak); \
|
ln_break(html_context, ei->linebreak); \
|
||||||
a = get_attr_val(attr, "id", html_context->options->cp); \
|
a = get_attr_val(attr, "id", html_context->doc_cp); \
|
||||||
if (a) { \
|
if (a) { \
|
||||||
html_context->special_f(html_context, SP_TAG, a); \
|
html_context->special_f(html_context, SP_TAG, a); \
|
||||||
mem_free(a); \
|
mem_free(a); \
|
||||||
@ -883,7 +883,7 @@ start_element(struct element_info *ei,
|
|||||||
html_top->linebreak = ei->linebreak;
|
html_top->linebreak = ei->linebreak;
|
||||||
|
|
||||||
#ifdef CONFIG_ECMASCRIPT
|
#ifdef CONFIG_ECMASCRIPT
|
||||||
if (has_attr(attr, "onClick", html_context->options->cp)) {
|
if (has_attr(attr, "onClick", html_context->doc_cp)) {
|
||||||
/* XXX: Put something better to format.link. --pasky */
|
/* XXX: Put something better to format.link. --pasky */
|
||||||
mem_free_set(&format.link, stracpy("javascript:void(0);"));
|
mem_free_set(&format.link, stracpy("javascript:void(0);"));
|
||||||
mem_free_set(&format.target, stracpy(html_context->base_target));
|
mem_free_set(&format.target, stracpy(html_context->base_target));
|
||||||
@ -1093,6 +1093,8 @@ xsp:
|
|||||||
}
|
}
|
||||||
if (strlcasecmp(name, namelen, "META", 4)) goto se;
|
if (strlcasecmp(name, namelen, "META", 4)) goto se;
|
||||||
|
|
||||||
|
/* FIXME (bug 784): options->cp is the terminal charset;
|
||||||
|
* should use the document charset instead. */
|
||||||
he = get_attr_val(attr, "charset", options->cp);
|
he = get_attr_val(attr, "charset", options->cp);
|
||||||
if (he) {
|
if (he) {
|
||||||
add_to_string(head, "Charset: ");
|
add_to_string(head, "Charset: ");
|
||||||
@ -1100,12 +1102,16 @@ xsp:
|
|||||||
mem_free(he);
|
mem_free(he);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* FIXME (bug 784): options->cp is the terminal charset;
|
||||||
|
* should use the document charset instead. */
|
||||||
he = get_attr_val(attr, "http-equiv", options->cp);
|
he = get_attr_val(attr, "http-equiv", options->cp);
|
||||||
if (!he) goto se;
|
if (!he) goto se;
|
||||||
|
|
||||||
add_to_string(head, he);
|
add_to_string(head, he);
|
||||||
mem_free(he);
|
mem_free(he);
|
||||||
|
|
||||||
|
/* FIXME (bug 784): options->cp is the terminal charset;
|
||||||
|
* should use the document charset instead. */
|
||||||
c = get_attr_val(attr, "content", options->cp);
|
c = get_attr_val(attr, "content", options->cp);
|
||||||
if (c) {
|
if (c) {
|
||||||
add_to_string(head, ": ");
|
add_to_string(head, ": ");
|
||||||
|
@ -90,7 +90,7 @@ kill_html_stack_item(struct html_context *html_context, struct html_element *e)
|
|||||||
* any element, executing it when that element is fully loaded. */
|
* any element, executing it when that element is fully loaded. */
|
||||||
if (e->options)
|
if (e->options)
|
||||||
onload = get_attr_val(e->options, "onLoad",
|
onload = get_attr_val(e->options, "onLoad",
|
||||||
html_context->options->cp);
|
html_context->doc_cp);
|
||||||
if (html_context->part
|
if (html_context->part
|
||||||
&& html_context->part->document
|
&& html_context->part->document
|
||||||
&& onload && *onload && *onload != '^') {
|
&& onload && *onload && *onload != '^') {
|
||||||
|
@ -70,12 +70,12 @@ get_bordercolor(struct html_context *html_context, unsigned char *a, color_T *rg
|
|||||||
if (!use_document_fg_colors(html_context->options))
|
if (!use_document_fg_colors(html_context->options))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
at = get_attr_val(a, "bordercolor", html_context->options->cp);
|
at = get_attr_val(a, "bordercolor", html_context->doc_cp);
|
||||||
/* Try some other MSIE-specific attributes if any. */
|
/* Try some other MSIE-specific attributes if any. */
|
||||||
if (!at)
|
if (!at)
|
||||||
at = get_attr_val(a, "bordercolorlight", html_context->options->cp);
|
at = get_attr_val(a, "bordercolorlight", html_context->doc_cp);
|
||||||
if (!at)
|
if (!at)
|
||||||
at = get_attr_val(a, "bordercolordark", html_context->options->cp);
|
at = get_attr_val(a, "bordercolordark", html_context->doc_cp);
|
||||||
if (!at) return;
|
if (!at) return;
|
||||||
|
|
||||||
decode_color(at, strlen(at), rgb);
|
decode_color(at, strlen(at), rgb);
|
||||||
@ -85,7 +85,7 @@ get_bordercolor(struct html_context *html_context, unsigned char *a, color_T *rg
|
|||||||
static void
|
static void
|
||||||
get_align(struct html_context *html_context, unsigned char *attr, int *a)
|
get_align(struct html_context *html_context, unsigned char *attr, int *a)
|
||||||
{
|
{
|
||||||
unsigned char *al = get_attr_val(attr, "align", html_context->options->cp);
|
unsigned char *al = get_attr_val(attr, "align", html_context->doc_cp);
|
||||||
|
|
||||||
if (!al) return;
|
if (!al) return;
|
||||||
|
|
||||||
@ -100,7 +100,7 @@ get_align(struct html_context *html_context, unsigned char *attr, int *a)
|
|||||||
static void
|
static void
|
||||||
get_valign(struct html_context *html_context, unsigned char *attr, int *a)
|
get_valign(struct html_context *html_context, unsigned char *attr, int *a)
|
||||||
{
|
{
|
||||||
unsigned char *al = get_attr_val(attr, "valign", html_context->options->cp);
|
unsigned char *al = get_attr_val(attr, "valign", html_context->doc_cp);
|
||||||
|
|
||||||
if (!al) return;
|
if (!al) return;
|
||||||
|
|
||||||
@ -115,7 +115,7 @@ static void
|
|||||||
get_column_width(unsigned char *attr, int *width, int sh,
|
get_column_width(unsigned char *attr, int *width, int sh,
|
||||||
struct html_context *html_context)
|
struct html_context *html_context)
|
||||||
{
|
{
|
||||||
unsigned char *al = get_attr_val(attr, "width", html_context->options->cp);
|
unsigned char *al = get_attr_val(attr, "width", html_context->doc_cp);
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
if (!al) return;
|
if (!al) return;
|
||||||
@ -151,7 +151,7 @@ set_table_frame(struct html_context *html_context, struct table *table,
|
|||||||
|
|
||||||
table->frame = TABLE_FRAME_BOX;
|
table->frame = TABLE_FRAME_BOX;
|
||||||
|
|
||||||
al = get_attr_val(attr, "frame", html_context->options->cp);
|
al = get_attr_val(attr, "frame", html_context->doc_cp);
|
||||||
if (!al) return;
|
if (!al) return;
|
||||||
|
|
||||||
if (!strcasecmp(al, "void")) table->frame = TABLE_FRAME_VOID;
|
if (!strcasecmp(al, "void")) table->frame = TABLE_FRAME_VOID;
|
||||||
@ -176,7 +176,7 @@ set_table_rules(struct html_context *html_context, struct table *table,
|
|||||||
|
|
||||||
table->rules = table->border ? TABLE_RULE_ALL : TABLE_RULE_NONE;
|
table->rules = table->border ? TABLE_RULE_ALL : TABLE_RULE_NONE;
|
||||||
|
|
||||||
al = get_attr_val(attr, "rules", html_context->options->cp);
|
al = get_attr_val(attr, "rules", html_context->doc_cp);
|
||||||
if (!al) return;
|
if (!al) return;
|
||||||
|
|
||||||
if (!strcasecmp(al, "none")) table->rules = TABLE_RULE_NONE;
|
if (!strcasecmp(al, "none")) table->rules = TABLE_RULE_NONE;
|
||||||
@ -191,7 +191,7 @@ static void
|
|||||||
parse_table_attributes(struct table *table, unsigned char *attr, int real,
|
parse_table_attributes(struct table *table, unsigned char *attr, int real,
|
||||||
struct html_context *html_context)
|
struct html_context *html_context)
|
||||||
{
|
{
|
||||||
table->fragment_id = get_attr_val(attr, "id", html_context->options->cp);
|
table->fragment_id = get_attr_val(attr, "id", html_context->doc_cp);
|
||||||
|
|
||||||
get_bordercolor(html_context, attr, &table->bordercolor);
|
get_bordercolor(html_context, attr, &table->bordercolor);
|
||||||
|
|
||||||
@ -212,18 +212,18 @@ parse_table_attributes(struct table *table, unsigned char *attr, int real,
|
|||||||
* interpreted as the value of the frame attribute. It implies
|
* interpreted as the value of the frame attribute. It implies
|
||||||
* rules="all" and some default (non-zero) value for the border
|
* rules="all" and some default (non-zero) value for the border
|
||||||
* attribute. */
|
* attribute. */
|
||||||
table->border = get_num(attr, "border", html_context->options->cp);
|
table->border = get_num(attr, "border", html_context->doc_cp);
|
||||||
if (table->border == -1) {
|
if (table->border == -1) {
|
||||||
table->border =
|
table->border =
|
||||||
has_attr(attr, "border", html_context->options->cp)
|
has_attr(attr, "border", html_context->doc_cp)
|
||||||
|| has_attr(attr, "rules", html_context->options->cp)
|
|| has_attr(attr, "rules", html_context->doc_cp)
|
||||||
|| has_attr(attr, "frame", html_context->options->cp);
|
|| has_attr(attr, "frame", html_context->doc_cp);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (table->border) {
|
if (table->border) {
|
||||||
int_upper_bound(&table->border, 2);
|
int_upper_bound(&table->border, 2);
|
||||||
|
|
||||||
table->cellspacing = get_num(attr, "cellspacing", html_context->options->cp);
|
table->cellspacing = get_num(attr, "cellspacing", html_context->doc_cp);
|
||||||
int_bounds(&table->cellspacing, 1, 2);
|
int_bounds(&table->cellspacing, 1, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -231,7 +231,7 @@ parse_table_attributes(struct table *table, unsigned char *attr, int real,
|
|||||||
|
|
||||||
/* TODO: cellpadding may be expressed as a percentage, this is not
|
/* TODO: cellpadding may be expressed as a percentage, this is not
|
||||||
* handled yet. */
|
* handled yet. */
|
||||||
table->cellpadding = get_num(attr, "cellpadding", html_context->options->cp);
|
table->cellpadding = get_num(attr, "cellpadding", html_context->doc_cp);
|
||||||
if (table->cellpadding == -1) {
|
if (table->cellpadding == -1) {
|
||||||
table->vcellpadding = 0;
|
table->vcellpadding = 0;
|
||||||
table->cellpadding = !!table->border;
|
table->cellpadding = !!table->border;
|
||||||
@ -650,7 +650,7 @@ see:
|
|||||||
get_align(html_context, t_attr, &c_al);
|
get_align(html_context, t_attr, &c_al);
|
||||||
get_valign(html_context, t_attr, &c_val);
|
get_valign(html_context, t_attr, &c_val);
|
||||||
get_column_width(t_attr, &c_width, sh, html_context);
|
get_column_width(t_attr, &c_width, sh, html_context);
|
||||||
c_span = get_num(t_attr, "span", html_context->options->cp);
|
c_span = get_num(t_attr, "span", html_context->doc_cp);
|
||||||
if (c_span == -1)
|
if (c_span == -1)
|
||||||
c_span = 1;
|
c_span = 1;
|
||||||
else if (c_span > HTML_MAX_COLSPAN)
|
else if (c_span > HTML_MAX_COLSPAN)
|
||||||
@ -668,7 +668,7 @@ see:
|
|||||||
|
|
||||||
add_table_bad_html_end(table, html);
|
add_table_bad_html_end(table, html);
|
||||||
|
|
||||||
sp = get_num(t_attr, "span", html_context->options->cp);
|
sp = get_num(t_attr, "span", html_context->doc_cp);
|
||||||
if (sp == -1) sp = 1;
|
if (sp == -1) sp = 1;
|
||||||
else if (sp > HTML_MAX_COLSPAN) sp = HTML_MAX_COLSPAN;
|
else if (sp > HTML_MAX_COLSPAN) sp = HTML_MAX_COLSPAN;
|
||||||
|
|
||||||
@ -745,7 +745,7 @@ see:
|
|||||||
get_valign(html_context, t_attr, &l_val);
|
get_valign(html_context, t_attr, &l_val);
|
||||||
get_bgcolor(html_context, t_attr, &last_bgcolor);
|
get_bgcolor(html_context, t_attr, &last_bgcolor);
|
||||||
mem_free_set(&l_fragment_id,
|
mem_free_set(&l_fragment_id,
|
||||||
get_attr_val(t_attr, "id", html_context->options->cp));
|
get_attr_val(t_attr, "id", html_context->doc_cp));
|
||||||
row++;
|
row++;
|
||||||
col = 0;
|
col = 0;
|
||||||
goto see;
|
goto see;
|
||||||
@ -788,7 +788,7 @@ see:
|
|||||||
|
|
||||||
cell->align = l_al;
|
cell->align = l_al;
|
||||||
cell->valign = l_val;
|
cell->valign = l_val;
|
||||||
cell->fragment_id = get_attr_val(t_attr, "id", html_context->options->cp);
|
cell->fragment_id = get_attr_val(t_attr, "id", html_context->doc_cp);
|
||||||
if (!cell->fragment_id && l_fragment_id) {
|
if (!cell->fragment_id && l_fragment_id) {
|
||||||
cell->fragment_id = l_fragment_id;
|
cell->fragment_id = l_fragment_id;
|
||||||
l_fragment_id = NULL;
|
l_fragment_id = NULL;
|
||||||
@ -812,12 +812,12 @@ see:
|
|||||||
get_valign(html_context, t_attr, &cell->valign);
|
get_valign(html_context, t_attr, &cell->valign);
|
||||||
get_bgcolor(html_context, t_attr, &cell->bgcolor);
|
get_bgcolor(html_context, t_attr, &cell->bgcolor);
|
||||||
|
|
||||||
colspan = get_num(t_attr, "colspan", html_context->options->cp);
|
colspan = get_num(t_attr, "colspan", html_context->doc_cp);
|
||||||
if (colspan == -1) colspan = 1;
|
if (colspan == -1) colspan = 1;
|
||||||
else if (!colspan) colspan = -1;
|
else if (!colspan) colspan = -1;
|
||||||
else if (colspan > HTML_MAX_COLSPAN) colspan = HTML_MAX_COLSPAN;
|
else if (colspan > HTML_MAX_COLSPAN) colspan = HTML_MAX_COLSPAN;
|
||||||
|
|
||||||
rowspan = get_num(t_attr, "rowspan", html_context->options->cp);
|
rowspan = get_num(t_attr, "rowspan", html_context->doc_cp);
|
||||||
if (rowspan == -1) rowspan = 1;
|
if (rowspan == -1) rowspan = 1;
|
||||||
else if (!rowspan) rowspan = -1;
|
else if (!rowspan) rowspan = -1;
|
||||||
else if (rowspan > HTML_MAX_ROWSPAN) rowspan = HTML_MAX_ROWSPAN;
|
else if (rowspan > HTML_MAX_ROWSPAN) rowspan = HTML_MAX_ROWSPAN;
|
||||||
|
@ -2240,6 +2240,7 @@ render_html_document(struct cache_entry *cached, struct document *document,
|
|||||||
#ifdef CONFIG_UTF8
|
#ifdef CONFIG_UTF8
|
||||||
html_context->options->utf8 = is_cp_utf8(document->options.cp);
|
html_context->options->utf8 = is_cp_utf8(document->options.cp);
|
||||||
#endif /* CONFIG_UTF8 */
|
#endif /* CONFIG_UTF8 */
|
||||||
|
html_context->doc_cp = document->cp;
|
||||||
|
|
||||||
if (title.length) {
|
if (title.length) {
|
||||||
document->title = convert_string(renderer_context.convert_table,
|
document->title = convert_string(renderer_context.convert_table,
|
||||||
|
Loading…
Reference in New Issue
Block a user