1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-10-02 03:46:21 -04:00

The massive attack: the only property of options used by get_attr_val was

cp (codepage). To fix bug 784 html_context->part->document->cp should
be passed to get_attr_val instead of html_context->options->cp.
This commit is contained in:
Witold Filipczyk 2006-08-05 18:06:28 +02:00 committed by Witold Filipczyk
parent 40e257bedd
commit 049d088e8a
9 changed files with 144 additions and 143 deletions

View File

@ -186,7 +186,7 @@ examine_element(struct html_context *html_context, struct css_selector *base,
process_found_selector(selector, CST_PSEUDO, base);
}
code = get_attr_val(element->options, "class", html_context->options);
code = get_attr_val(element->options, "class", html_context->options->cp);
if (code && seltype <= CST_CLASS) {
unsigned char *class = code;
@ -203,7 +203,7 @@ examine_element(struct html_context *html_context, struct css_selector *base,
}
mem_free_if(code);
code = get_attr_val(element->options, "id", html_context->options);
code = get_attr_val(element->options, "id", html_context->options->cp);
if (code && seltype <= CST_ID) {
selector = find_css_selector(selectors, CST_ID, rel, code, -1);
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);
#endif
code = get_attr_val(element->options, "style", html_context->options);
code = get_attr_val(element->options, "style", html_context->options->cp);
if (code) {
struct css_selector *stylesel;
struct scanner scanner;

View File

@ -57,7 +57,7 @@ get_color(struct html_context *html_context, unsigned char *a,
if (!use_document_fg_colors(html_context->options))
return -1;
at = get_attr_val(a, c, html_context->options);
at = get_attr_val(a, c, html_context->options->cp);
if (!at) return -1;
r = decode_color(at, strlen(at), rgb);
@ -78,7 +78,7 @@ get_bgcolor(struct html_context *html_context, unsigned char *a, color_T *rgb)
unsigned char *
get_target(struct document_options *options, unsigned char *a)
{
unsigned char *v = get_attr_val(a, "target", options);
unsigned char *v = get_attr_val(a, "target", options->cp);
if (!v) return NULL;
@ -154,7 +154,7 @@ set_fragment_identifier(struct html_context *html_context,
{
unsigned char *id_attr;
id_attr = get_attr_val(attr_name, attr, html_context->options);
id_attr = get_attr_val(attr_name, attr, html_context->options->cp);
if (id_attr) {
html_context->special_f(html_context, SP_TAG, id_attr);
@ -226,6 +226,7 @@ html_focusable(struct html_context *html_context, unsigned char *a)
{
struct document_options *options;
unsigned char *accesskey;
int cp;
int tabindex;
format.accesskey = 0;
@ -234,25 +235,26 @@ html_focusable(struct html_context *html_context, unsigned char *a)
if (!a) return;
options = html_context->options;
cp = options->cp;
accesskey = get_attr_val(a, "accesskey", options);
accesskey = get_attr_val(a, "accesskey", cp);
if (accesskey) {
format.accesskey = accesskey_string_to_unicode(accesskey);
mem_free(accesskey);
}
tabindex = get_num(a, "tabindex", options);
tabindex = get_num(a, "tabindex", options->cp);
if (0 < tabindex && tabindex < 32767) {
format.tabindex = (tabindex & 0x7fff) << 16;
}
mem_free_set(&format.onclick, get_attr_val(a, "onclick", options));
mem_free_set(&format.ondblclick, get_attr_val(a, "ondblclick", options));
mem_free_set(&format.onmouseover, get_attr_val(a, "onmouseover", options));
mem_free_set(&format.onhover, get_attr_val(a, "onhover", options));
mem_free_set(&format.onfocus, get_attr_val(a, "onfocus", options));
mem_free_set(&format.onmouseout, get_attr_val(a, "onmouseout", options));
mem_free_set(&format.onblur, get_attr_val(a, "onblur", options));
mem_free_set(&format.onclick, get_attr_val(a, "onclick", cp));
mem_free_set(&format.ondblclick, get_attr_val(a, "ondblclick", cp));
mem_free_set(&format.onmouseover, get_attr_val(a, "onmouseover", cp));
mem_free_set(&format.onhover, get_attr_val(a, "onhover", cp));
mem_free_set(&format.onfocus, get_attr_val(a, "onfocus", cp));
mem_free_set(&format.onmouseout, get_attr_val(a, "onmouseout", cp));
mem_free_set(&format.onblur, get_attr_val(a, "onblur", cp));
}
void
@ -448,7 +450,7 @@ look_for_map(unsigned char **pos, unsigned char *eof, struct uri *uri,
if (strlcasecmp(name, namelen, "MAP", 3)) return 1;
if (uri && uri->fragment) {
al = get_attr_val(attr, "name", options);
al = get_attr_val(attr, "name", options->cp);
if (!al) return 1;
if (strlcasecmp(al, -1, uri->fragment, uri->fragmentlen)) {
@ -546,7 +548,7 @@ look_for_link(unsigned char **pos, unsigned char *eof, struct menu_item **menu,
if (*pos >= eof) return 0;
} else if (!strlcasecmp(name, namelen, "AREA", 4)) {
unsigned char *alt = get_attr_val(attr, "alt", options);
unsigned char *alt = get_attr_val(attr, "alt", options->cp);
if (alt) {
label = convert_string(ct, alt, strlen(alt),
@ -580,7 +582,7 @@ look_for_link(unsigned char **pos, unsigned char *eof, struct menu_item **menu,
return 1;
}
href = get_url_val(attr, "href", options);
href = get_url_val(attr, "href", options->cp);
if (!href) {
mem_free_if(label);
mem_free(target);

View File

@ -50,13 +50,13 @@ html_form(struct html_context *html_context, unsigned char *a,
form->method = FORM_METHOD_GET;
form->form_num = a - html_context->startf;
al = get_attr_val(a, "method", html_context->options);
al = get_attr_val(a, "method", html_context->options->cp);
if (al) {
if (!strcasecmp(al, "post")) {
unsigned char *enctype;
enctype = get_attr_val(a, "enctype",
html_context->options);
html_context->options->cp);
form->method = FORM_METHOD_POST;
if (enctype) {
@ -69,11 +69,11 @@ html_form(struct html_context *html_context, unsigned char *a,
}
mem_free(al);
}
form->onsubmit = get_attr_val(a, "onsubmit", html_context->options);
al = get_attr_val(a, "name", html_context->options);
form->onsubmit = get_attr_val(a, "onsubmit", html_context->options->cp);
al = get_attr_val(a, "name", html_context->options->cp);
if (al) form->name = al;
al = get_attr_val(a, "action", html_context->options);
al = get_attr_val(a, "action", html_context->options->cp);
/* The HTML specification at
* 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.
@ -114,10 +114,10 @@ html_form(struct html_context *html_context, unsigned char *a,
static int
get_form_mode(struct html_context *html_context, unsigned char *attr)
{
if (has_attr(attr, "disabled", html_context->options))
if (has_attr(attr, "disabled", html_context->options->cp))
return FORM_MODE_DISABLED;
if (has_attr(attr, "readonly", html_context->options))
if (has_attr(attr, "readonly", html_context->options->cp))
return FORM_MODE_READONLY;
return FORM_MODE_NORMAL;
@ -149,7 +149,7 @@ html_button(struct html_context *html_context, unsigned char *a,
html_focusable(html_context, a);
al = get_attr_val(a, "type", html_context->options);
al = get_attr_val(a, "type", html_context->options->cp);
if (!al) goto no_type_attr;
if (!strcasecmp(al, "button")) {
@ -167,9 +167,9 @@ no_type_attr:
fc = init_form_control(type, a, html_context);
if (!fc) return;
fc->id = get_attr_val(a, "id", html_context->options);
fc->name = get_attr_val(a, "name", html_context->options);
fc->default_value = get_attr_val(a, "value", html_context->options);
fc->id = get_attr_val(a, "id", html_context->options->cp);
fc->name = get_attr_val(a, "name", html_context->options->cp);
fc->default_value = get_attr_val(a, "value", html_context->options->cp);
if (!fc->default_value) {
if (fc->type == FC_SUBMIT)
fc->default_value = stracpy("Submit");
@ -195,7 +195,7 @@ html_input_format(struct html_context *html_context, unsigned char *a,
html_focusable(html_context, a);
format.form = fc;
if (format.title) mem_free(format.title);
format.title = get_attr_val(a, "title", html_context->options);
format.title = get_attr_val(a, "title", html_context->options->cp);
switch (fc->type) {
case FC_TEXT:
case FC_PASSWORD:
@ -221,10 +221,10 @@ html_input_format(struct html_context *html_context, unsigned char *a,
unsigned char *al;
mem_free_set(&format.image, NULL);
al = get_url_val(a, "src", html_context->options);
al = get_url_val(a, "src", html_context->options->cp);
if (!al)
al = get_url_val(a, "dynsrc",
html_context->options);
html_context->options->cp);
if (al) {
format.image = join_urls(html_context->base_href, al);
mem_free(al);
@ -269,7 +269,7 @@ html_input(struct html_context *html_context, unsigned char *a,
fc = init_form_control(FC_TEXT, a, html_context);
if (!fc) return;
al = get_attr_val(a, "type", html_context->options);
al = get_attr_val(a, "type", html_context->options->cp);
if (al) {
if (!strcasecmp(al, "text")) fc->type = FC_TEXT;
else if (!strcasecmp(al, "hidden")) fc->type = FC_HIDDEN;
@ -287,7 +287,7 @@ html_input(struct html_context *html_context, unsigned char *a,
if (fc->type != FC_FILE)
fc->default_value = get_attr_val(a, "value",
html_context->options);
html_context->options->cp);
if (!fc->default_value) {
if (fc->type == FC_CHECKBOX)
fc->default_value = stracpy("on");
@ -301,22 +301,22 @@ html_input(struct html_context *html_context, unsigned char *a,
if (!fc->default_value)
fc->default_value = stracpy("");
fc->id = get_attr_val(a, "id", html_context->options);
fc->name = get_attr_val(a, "name", html_context->options);
fc->id = get_attr_val(a, "id", html_context->options->cp);
fc->name = get_attr_val(a, "name", html_context->options->cp);
fc->size = get_num(a, "size", html_context->options);
fc->size = get_num(a, "size", html_context->options->cp);
if (fc->size == -1)
fc->size = html_context->options->default_form_input_size;
fc->size++;
if (fc->size > html_context->options->box.width)
fc->size = html_context->options->box.width;
fc->maxlength = get_num(a, "maxlength", html_context->options);
fc->maxlength = get_num(a, "maxlength", html_context->options->cp);
if (fc->maxlength == -1) fc->maxlength = INT_MAX;
if (fc->type == FC_CHECKBOX || fc->type == FC_RADIO)
fc->default_state = has_attr(a, "checked",
html_context->options);
html_context->options->cp);
if (fc->type == FC_IMAGE)
fc->alt = get_attr_val(a, "alt", html_context->options);
fc->alt = get_attr_val(a, "alt", html_context->options->cp);
if (fc->type != FC_HIDDEN) {
html_input_format(html_context, a, fc);
@ -419,18 +419,18 @@ abort:
if (!closing_tag) {
unsigned char *value, *label;
if (has_attr(t_attr, "disabled", html_context->options))
if (has_attr(t_attr, "disabled", html_context->options->cp))
goto see;
if (preselect == -1
&& has_attr(t_attr, "selected", html_context->options))
&& has_attr(t_attr, "selected", html_context->options->cp))
preselect = order;
value = get_attr_val(t_attr, "value", html_context->options);
value = get_attr_val(t_attr, "value", html_context->options->cp);
if (!mem_align_alloc(&values, order, order + 1, 0xFF))
goto abort;
values[order++] = value;
label = get_attr_val(t_attr, "label", html_context->options);
label = get_attr_val(t_attr, "label", html_context->options->cp);
if (label) new_menu_item(&lnk_menu, label, order - 1, 0);
if (!value || !label) {
init_string(&lbl);
@ -450,7 +450,7 @@ abort:
if (!closing_tag) {
unsigned char *label;
label = get_attr_val(t_attr, "label", html_context->options);
label = get_attr_val(t_attr, "label", html_context->options->cp);
if (!label) {
label = stracpy("");
@ -477,8 +477,8 @@ end_parse:
goto abort;
}
fc->id = get_attr_val(attr, "id", html_context->options);
fc->name = get_attr_val(attr, "name", html_context->options);
fc->id = get_attr_val(attr, "id", html_context->options->cp);
fc->name = get_attr_val(attr, "name", html_context->options->cp);
fc->default_state = preselect < 0 ? 0 : preselect;
fc->default_value = order ? stracpy(values[fc->default_state]) : stracpy("");
fc->nvalues = order;
@ -518,13 +518,13 @@ 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);
unsigned char *al = get_attr_val(a, "name", html_context->options->cp);
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)
format.select_disabled = has_attr(a, "disabled", html_context->options->cp)
? FORM_MODE_DISABLED
: FORM_MODE_NORMAL;
}
@ -533,7 +533,7 @@ void
html_select(struct html_context *html_context, unsigned char *a,
unsigned char *html, unsigned char *eof, unsigned char **end)
{
if (has_attr(a, "multiple", html_context->options))
if (has_attr(a, "multiple", html_context->options->cp))
do_html_select_multiple(html_context, a, html, eof, end);
else
do_html_select(a, html, eof, end, html_context);
@ -549,7 +549,7 @@ html_option(struct html_context *html_context, unsigned char *a,
if (!format.select) return;
val = get_attr_val(a, "value", html_context->options);
val = get_attr_val(a, "value", html_context->options->cp);
if (!val) {
struct string str;
unsigned char *p, *r;
@ -600,11 +600,11 @@ end_parse:
return;
}
fc->id = get_attr_val(a, "id", html_context->options);
fc->id = get_attr_val(a, "id", html_context->options->cp);
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)
fc->default_state = has_attr(a, "selected", html_context->options->cp);
fc->mode = has_attr(a, "disabled", html_context->options->cp)
? FORM_MODE_DISABLED
: format.select_disabled;
@ -646,8 +646,8 @@ pp:
fc = init_form_control(FC_TEXTAREA, attr, html_context);
if (!fc) return;
fc->id = get_attr_val(attr, "id", html_context->options);
fc->name = get_attr_val(attr, "name", html_context->options);
fc->id = get_attr_val(attr, "id", html_context->options->cp);
fc->name = get_attr_val(attr, "name", html_context->options->cp);
fc->default_value = memacpy(html, p - html);
for (p = fc->default_value; p && p[0]; p++) {
/* FIXME: We don't cope well with entities here. Bugzilla uses
@ -664,7 +664,7 @@ pp:
}
}
cols = get_num(attr, "cols", html_context->options);
cols = get_num(attr, "cols", html_context->options->cp);
if (cols <= 0)
cols = html_context->options->default_form_input_size;
cols++; /* Add 1 column, other browsers may have different
@ -673,14 +673,14 @@ pp:
cols = html_context->options->box.width;
fc->cols = cols;
rows = get_num(attr, "rows", html_context->options);
rows = get_num(attr, "rows", html_context->options->cp);
if (rows <= 0) rows = 1;
if (rows > html_context->options->box.height)
rows = html_context->options->box.height;
fc->rows = rows;
html_context->options->needs_height = 1;
wrap_attr = get_attr_val(attr, "wrap", html_context->options);
wrap_attr = get_attr_val(attr, "wrap", html_context->options->cp);
if (wrap_attr) {
if (!strcasecmp(wrap_attr, "hard")
|| !strcasecmp(wrap_attr, "physical")) {
@ -694,14 +694,14 @@ pp:
}
mem_free(wrap_attr);
} else if (has_attr(attr, "nowrap", html_context->options)) {
} else if (has_attr(attr, "nowrap", html_context->options->cp)) {
fc->wrap = FORM_WRAP_NONE;
} else {
fc->wrap = FORM_WRAP_SOFT;
}
fc->maxlength = get_num(attr, "maxlength", html_context->options);
fc->maxlength = get_num(attr, "maxlength", html_context->options->cp);
if (fc->maxlength == -1) fc->maxlength = INT_MAX;
if (rows > 1) ln_break(html_context, 1);

View File

@ -123,7 +123,7 @@ void
html_font(struct html_context *html_context, unsigned char *a,
unsigned char *xxx3, unsigned char *xxx4, unsigned char **xxx5)
{
unsigned char *al = get_attr_val(a, "size", html_context->options);
unsigned char *al = get_attr_val(a, "size", html_context->options->cp);
if (al) {
int p = 0;
@ -210,7 +210,7 @@ html_script(struct html_context *html_context, unsigned char *a,
/* Ref:
* http://www.ietf.org/internet-drafts/draft-hoehrmann-script-types-03.txt
*/
type = get_attr_val(a, "type", html_context->options);
type = get_attr_val(a, "type", html_context->options->cp);
if (type) {
unsigned char *pos = type;
@ -252,7 +252,7 @@ not_processed:
* 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);
language = get_attr_val(a, "language", html_context->options->cp);
if (language) {
int languagelen = strlen(language);
@ -267,7 +267,7 @@ not_processed:
}
if (html_context->part->document
&& (src = get_attr_val(a, "src", html_context->options))) {
&& (src = get_attr_val(a, "src", html_context->options->cp))) {
/* External reference. */
unsigned char *import_url;
@ -466,7 +466,7 @@ void
html_linebrk(struct html_context *html_context, unsigned char *a,
unsigned char *xxx3, unsigned char *xxx4, unsigned char **xxx5)
{
unsigned char *al = get_attr_val(a, "align", html_context->options);
unsigned char *al = get_attr_val(a, "align", html_context->options->cp);
if (al) {
if (!strcasecmp(al, "left")) par_format.align = ALIGN_LEFT;
@ -619,7 +619,7 @@ html_hr(struct html_context *html_context, unsigned char *a,
{
int i/* = par_format.width - 10*/;
unsigned char r = (unsigned char) BORDER_DHLINE;
int q = get_num(a, "size", html_context->options);
int q = get_num(a, "size", html_context->options->cp);
if (q >= 0 && q < 2) r = (unsigned char) BORDER_SHLINE;
html_stack_dup(html_context, ELEMENT_KILLABLE);
@ -701,7 +701,7 @@ html_base(struct html_context *html_context, unsigned char *a,
{
unsigned char *al;
al = get_url_val(a, "href", html_context->options);
al = get_url_val(a, "href", html_context->options->cp);
if (al) {
unsigned char *base = join_urls(html_context->base_href, al);
struct uri *uri = base ? get_uri(base, 0) : NULL;
@ -730,7 +730,7 @@ html_ul(struct html_context *html_context, unsigned char *a,
par_format.list_number = 0;
par_format.flags = P_STAR;
al = get_attr_val(a, "type", html_context->options);
al = get_attr_val(a, "type", html_context->options->cp);
if (al) {
if (!strcasecmp(al, "disc") || !strcasecmp(al, "circle"))
par_format.flags = P_O;
@ -754,12 +754,12 @@ html_ol(struct html_context *html_context, unsigned char *a,
int st;
par_format.list_level++;
st = get_num(a, "start", html_context->options);
st = get_num(a, "start", html_context->options->cp);
if (st == -1) st = 1;
par_format.list_number = st;
par_format.flags = P_NUMBER;
al = get_attr_val(a, "type", html_context->options);
al = get_attr_val(a, "type", html_context->options->cp);
if (al) {
if (*al && !al[1]) {
if (*al == '1') par_format.flags = P_NUMBER;
@ -862,7 +862,7 @@ html_li(struct html_context *html_context, unsigned char *a,
unsigned char n[32];
int nlen;
int t = par_format.flags & P_LISTMASK;
int s = get_num(a, "value", html_context->options);
int s = get_num(a, "value", html_context->options->cp);
if (s != -1) par_format.list_number = s;
@ -919,7 +919,7 @@ html_dl(struct html_context *html_context, unsigned char *a,
unsigned char *xxx3, unsigned char *xxx4, unsigned char **xxx5)
{
par_format.flags &= ~P_COMPACT;
if (has_attr(a, "compact", html_context->options))
if (has_attr(a, "compact", html_context->options->cp))
par_format.flags |= P_COMPACT;
if (par_format.list_level) par_format.leftmargin += 5;
par_format.list_level++;
@ -941,7 +941,7 @@ html_dt(struct html_context *html_context, unsigned char *a,
par_format.align = ALIGN_LEFT;
par_format.leftmargin = par_format.dd_margin;
if (!(par_format.flags & P_COMPACT)
&& !has_attr(a, "compact", html_context->options))
&& !has_attr(a, "compact", html_context->options->cp))
ln_break(html_context, 2);
}
@ -982,7 +982,7 @@ html_frame(struct html_context *html_context, unsigned char *a,
{
unsigned char *name, *src, *url;
src = get_url_val(a, "src", html_context->options);
src = get_url_val(a, "src", html_context->options->cp);
if (!src) {
url = stracpy("about:blank");
} else {
@ -991,7 +991,7 @@ html_frame(struct html_context *html_context, unsigned char *a,
}
if (!url) return;
name = get_attr_val(a, "name", html_context->options);
name = get_attr_val(a, "name", html_context->options->cp);
if (!name) {
name = stracpy(url);
} else if (!name[0]) {
@ -1035,13 +1035,13 @@ html_frameset(struct html_context *html_context, unsigned char *a,
|| !html_context->special_f(html_context, SP_USED, NULL))
return;
cols = get_attr_val(a, "cols", html_context->options);
cols = get_attr_val(a, "cols", html_context->options->cp);
if (!cols) {
cols = stracpy("100%");
if (!cols) return;
}
rows = get_attr_val(a, "rows", html_context->options);
rows = get_attr_val(a, "rows", html_context->options->cp);
if (!rows) {
rows = stracpy("100%");
if (!rows) {

View File

@ -45,7 +45,7 @@ html_a(struct html_context *html_context, unsigned char *a,
{
unsigned char *href;
href = get_url_val(a, "href", html_context->options);
href = get_url_val(a, "href", html_context->options->cp);
if (href) {
unsigned char *target;
@ -84,7 +84,7 @@ html_a(struct html_context *html_context, unsigned char *a,
}
mem_free_set(&format.title,
get_attr_val(a, "title", html_context->options));
get_attr_val(a, "title", html_context->options->cp));
html_focusable(html_context, a);
@ -222,7 +222,7 @@ html_img_do(unsigned char *a, unsigned char *object_src,
* 2 means display alt/title attribute if possible, IMG if not
* 3 means display alt/title attribute if possible, filename if not */
usemap_attr = get_attr_val(a, "usemap", options);
usemap_attr = get_attr_val(a, "usemap", options->cp);
if (usemap_attr) {
unsigned char *joined_urls = join_urls(html_context->base_href,
usemap_attr);
@ -242,13 +242,13 @@ html_img_do(unsigned char *a, unsigned char *object_src,
}
ismap = format.link
&& has_attr(a, "ismap", options)
&& has_attr(a, "ismap", options->cp)
&& !usemap;
if (display_style == 2 || display_style == 3) {
label = get_attr_val(a, "alt", options);
label = get_attr_val(a, "alt", options->cp);
if (!label)
label = get_attr_val(a, "title", options);
label = get_attr_val(a, "title", options->cp);
/* Little hack to preserve rendering of [ ], in directories listing,
* but we still want to drop extra spaces in alt or title attribute
@ -257,8 +257,8 @@ html_img_do(unsigned char *a, unsigned char *object_src,
}
src = null_or_stracpy(object_src);
if (!src) src = get_url_val(a, "src", options);
if (!src) src = get_url_val(a, "dynsrc", options);
if (!src) src = get_url_val(a, "src", options->cp);
if (!src) src = get_url_val(a, "dynsrc", options->cp);
/* If we have no label yet (no title or alt), so
* just use default ones, or image filename. */
@ -319,7 +319,7 @@ html_img_do(unsigned char *a, unsigned char *object_src,
format.image = join_urls(html_context->base_href, src);
}
format.title = get_attr_val(a, "title", options);
format.title = get_attr_val(a, "title", options->cp);
if (ismap) {
unsigned char *new_link;
@ -379,10 +379,10 @@ html_applet(struct html_context *html_context, unsigned char *a,
{
unsigned char *code, *alt;
code = get_url_val(a, "code", html_context->options);
code = get_url_val(a, "code", html_context->options->cp);
if (!code) return;
alt = get_attr_val(a, "alt", html_context->options);
alt = get_attr_val(a, "alt", html_context->options->cp);
html_focusable(html_context, a);
@ -405,11 +405,11 @@ html_iframe_do(unsigned char *a, unsigned char *object_src,
unsigned char *name, *url = NULL;
url = null_or_stracpy(object_src);
if (!url) url = get_url_val(a, "src", html_context->options);
if (!url) url = get_url_val(a, "src", html_context->options->cp);
if (!url) return;
name = get_attr_val(a, "name", html_context->options);
if (!name) name = get_attr_val(a, "id", html_context->options);
name = get_attr_val(a, "name", html_context->options->cp);
if (!name) name = get_attr_val(a, "id", html_context->options->cp);
if (!name) name = stracpy("");
if (!name) {
mem_free(url);
@ -447,11 +447,11 @@ html_object(struct html_context *html_context, unsigned char *a,
* this, which is anyway in the spirit of <object> element, unifying
* <img> and <iframe> etc. */
url = get_url_val(a, "data", html_context->options);
if (!url) url = get_url_val(a, "codebase", html_context->options);
url = get_url_val(a, "data", html_context->options->cp);
if (!url) url = get_url_val(a, "codebase", html_context->options->cp);
if (!url) return;
type = get_attr_val(a, "type", html_context->options);
type = get_attr_val(a, "type", html_context->options->cp);
if (!type) { mem_free(url); return; }
if (!strncasecmp(type, "text/", 5)) {
@ -466,7 +466,7 @@ html_object(struct html_context *html_context, unsigned char *a,
} else {
unsigned char *name;
name = get_attr_val(a, "standby", html_context->options);
name = get_attr_val(a, "standby", html_context->options->cp);
html_focusable(html_context, a);
@ -498,7 +498,7 @@ html_embed(struct html_context *html_context, unsigned char *a,
* this, which is anyway in the spirit of <object> element, unifying
* <img> and <iframe> etc. */
object_src = get_url_val(a, "src", html_context->options);
object_src = get_url_val(a, "src", html_context->options->cp);
if (!object_src || !*object_src) {
mem_free_set(&object_src, NULL);
return;
@ -727,20 +727,20 @@ html_link_parse(struct html_context *html_context, unsigned char *a,
assert(a && link);
memset(link, 0, sizeof(*link));
link->href = get_url_val(a, "href", html_context->options);
link->href = get_url_val(a, "href", html_context->options->cp);
if (!link->href) return 0;
link->lang = get_attr_val(a, "lang", html_context->options);
link->hreflang = get_attr_val(a, "hreflang", html_context->options);
link->title = get_attr_val(a, "title", html_context->options);
link->content_type = get_attr_val(a, "type", html_context->options);
link->media = get_attr_val(a, "media", html_context->options);
link->lang = get_attr_val(a, "lang", html_context->options->cp);
link->hreflang = get_attr_val(a, "hreflang", html_context->options->cp);
link->title = get_attr_val(a, "title", html_context->options->cp);
link->content_type = get_attr_val(a, "type", html_context->options->cp);
link->media = get_attr_val(a, "media", html_context->options->cp);
link->name = get_attr_val(a, "rel", html_context->options);
link->name = get_attr_val(a, "rel", html_context->options->cp);
if (link->name) {
link->direction = LD_REL;
} else {
link->name = get_attr_val(a, "rev", html_context->options);
link->name = get_attr_val(a, "rev", html_context->options->cp);
if (link->name) link->direction = LD_REV;
}

View File

@ -136,7 +136,7 @@ end:
unsigned char *
get_attr_value(register unsigned char *e, unsigned char *name,
struct document_options *options, enum html_attr_flags flags)
int cp, enum html_attr_flags flags)
{
unsigned char *n;
unsigned char *name_start;
@ -206,9 +206,8 @@ found_endattr:
memchr(attr, '&', attrlen)) {
unsigned char *saved_attr = attr;
attr = convert_string(NULL, saved_attr, attrlen,
options->cp, CSM_QUERY,
NULL, NULL, NULL);
attr = convert_string(NULL, saved_attr, attrlen, cp,
CSM_QUERY, NULL, NULL, NULL);
mem_free(saved_attr);
}
@ -246,9 +245,9 @@ parse_error:
* It will return a positive integer value on success,
* or -1 on error. */
int
get_num(unsigned char *a, unsigned char *name, struct document_options *options)
get_num(unsigned char *a, unsigned char *name, int cp)
{
unsigned char *al = get_attr_val(a, name, options);
unsigned char *al = get_attr_val(a, name, cp);
int result = -1;
if (al) {
@ -274,7 +273,7 @@ int
get_width(unsigned char *a, unsigned char *name, int limited,
struct html_context *html_context)
{
unsigned char *value = get_attr_val(a, name, html_context->options);
unsigned char *value = get_attr_val(a, name, html_context->options->cp);
unsigned char *str = value;
unsigned char *end;
int percentage = 0;
@ -755,7 +754,7 @@ start_element(struct element_info *ei,
{
#define ELEMENT_RENDER_PROLOGUE \
ln_break(html_context, ei->linebreak); \
a = get_attr_val(attr, "id", html_context->options); \
a = get_attr_val(attr, "id", html_context->options->cp); \
if (a) { \
html_context->special_f(html_context, SP_TAG, a); \
mem_free(a); \
@ -1039,20 +1038,20 @@ xsp:
}
if (strlcasecmp(name, namelen, "META", 4)) goto se;
he = get_attr_val(attr, "charset", options);
he = get_attr_val(attr, "charset", options->cp);
if (he) {
add_to_string(head, "Charset: ");
add_to_string(head, he);
mem_free(he);
}
he = get_attr_val(attr, "http-equiv", options);
he = get_attr_val(attr, "http-equiv", options->cp);
if (!he) goto se;
add_to_string(head, he);
mem_free(he);
c = get_attr_val(attr, "content", options);
c = get_attr_val(attr, "content", options->cp);
if (c) {
add_to_string(head, ": ");
add_to_string(head, c);

View File

@ -33,12 +33,12 @@ enum html_attr_flags {
* - name is searched attribute
*
* Returns allocated string containing the attribute, or NULL on unsuccess. */
unsigned char *get_attr_value(register unsigned char *e, unsigned char *name, struct document_options *options, enum html_attr_flags flags);
unsigned char *get_attr_value(register unsigned char *e, unsigned char *name, int cp, enum html_attr_flags flags);
/* Wrappers for get_attr_value(). */
#define get_attr_val(e, name, options) get_attr_value(e, name, options, HTML_ATTR_NONE)
#define get_url_val(e, name, options) get_attr_value(e, name, options, HTML_ATTR_EAT_NL)
#define has_attr(e, name, options) (!!get_attr_value(e, name, options, HTML_ATTR_TEST))
#define get_attr_val(e, name, cp) get_attr_value(e, name, cp, HTML_ATTR_NONE)
#define get_url_val(e, name, cp) get_attr_value(e, name, cp, HTML_ATTR_EAT_NL)
#define has_attr(e, name, cp) (!!get_attr_value(e, name, cp, HTML_ATTR_TEST))
/* Interface for both the renderer and the table handling */
@ -55,7 +55,7 @@ typedef void (element_handler_T)(struct html_context *, unsigned char *attr,
int parse_element(unsigned char *, unsigned char *, unsigned char **, int *, unsigned char **, unsigned char **);
int get_num(unsigned char *, unsigned char *, struct document_options *);
int get_num(unsigned char *, unsigned char *, int);
int get_width(unsigned char *, unsigned char *, int, struct html_context *);
unsigned char *skip_comment(unsigned char *, unsigned char *);

View File

@ -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. */
if (e->options)
onload = get_attr_val(e->options, "onLoad",
html_context->options);
html_context->options->cp);
if (html_context->part
&& html_context->part->document
&& onload && *onload && *onload != '^') {

View File

@ -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))
return;
at = get_attr_val(a, "bordercolor", html_context->options);
at = get_attr_val(a, "bordercolor", html_context->options->cp);
/* Try some other MSIE-specific attributes if any. */
if (!at)
at = get_attr_val(a, "bordercolorlight", html_context->options);
at = get_attr_val(a, "bordercolorlight", html_context->options->cp);
if (!at)
at = get_attr_val(a, "bordercolordark", html_context->options);
at = get_attr_val(a, "bordercolordark", html_context->options->cp);
if (!at) return;
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
get_align(struct html_context *html_context, unsigned char *attr, int *a)
{
unsigned char *al = get_attr_val(attr, "align", html_context->options);
unsigned char *al = get_attr_val(attr, "align", html_context->options->cp);
if (!al) return;
@ -100,7 +100,7 @@ get_align(struct html_context *html_context, unsigned char *attr, int *a)
static void
get_valign(struct html_context *html_context, unsigned char *attr, int *a)
{
unsigned char *al = get_attr_val(attr, "valign", html_context->options);
unsigned char *al = get_attr_val(attr, "valign", html_context->options->cp);
if (!al) return;
@ -115,7 +115,7 @@ static void
get_column_width(unsigned char *attr, int *width, int sh,
struct html_context *html_context)
{
unsigned char *al = get_attr_val(attr, "width", html_context->options);
unsigned char *al = get_attr_val(attr, "width", html_context->options->cp);
int len;
if (!al) return;
@ -151,7 +151,7 @@ set_table_frame(struct html_context *html_context, struct table *table,
table->frame = TABLE_FRAME_BOX;
al = get_attr_val(attr, "frame", html_context->options);
al = get_attr_val(attr, "frame", html_context->options->cp);
if (!al) return;
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;
al = get_attr_val(attr, "rules", html_context->options);
al = get_attr_val(attr, "rules", html_context->options->cp);
if (!al) return;
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,
struct html_context *html_context)
{
table->fragment_id = get_attr_val(attr, "id", html_context->options);
table->fragment_id = get_attr_val(attr, "id", html_context->options->cp);
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
* rules="all" and some default (non-zero) value for the border
* attribute. */
table->border = get_num(attr, "border", html_context->options);
table->border = get_num(attr, "border", html_context->options->cp);
if (table->border == -1) {
table->border =
has_attr(attr, "border", html_context->options)
|| has_attr(attr, "rules", html_context->options)
|| has_attr(attr, "frame", html_context->options);
has_attr(attr, "border", html_context->options->cp)
|| has_attr(attr, "rules", html_context->options->cp)
|| has_attr(attr, "frame", html_context->options->cp);
}
if (table->border) {
int_upper_bound(&table->border, 2);
table->cellspacing = get_num(attr, "cellspacing", html_context->options);
table->cellspacing = get_num(attr, "cellspacing", html_context->options->cp);
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
* handled yet. */
table->cellpadding = get_num(attr, "cellpadding", html_context->options);
table->cellpadding = get_num(attr, "cellpadding", html_context->options->cp);
if (table->cellpadding == -1) {
table->vcellpadding = 0;
table->cellpadding = !!table->border;
@ -650,7 +650,7 @@ see:
get_align(html_context, t_attr, &c_al);
get_valign(html_context, t_attr, &c_val);
get_column_width(t_attr, &c_width, sh, html_context);
c_span = get_num(t_attr, "span", html_context->options);
c_span = get_num(t_attr, "span", html_context->options->cp);
if (c_span == -1)
c_span = 1;
else if (c_span > HTML_MAX_COLSPAN)
@ -668,7 +668,7 @@ see:
add_table_bad_html_end(table, html);
sp = get_num(t_attr, "span", html_context->options);
sp = get_num(t_attr, "span", html_context->options->cp);
if (sp == -1) sp = 1;
else if (sp > HTML_MAX_COLSPAN) sp = HTML_MAX_COLSPAN;
@ -745,7 +745,7 @@ see:
get_valign(html_context, t_attr, &l_val);
get_bgcolor(html_context, t_attr, &last_bgcolor);
mem_free_set(&l_fragment_id,
get_attr_val(t_attr, "id", html_context->options));
get_attr_val(t_attr, "id", html_context->options->cp));
row++;
col = 0;
goto see;
@ -788,7 +788,7 @@ see:
cell->align = l_al;
cell->valign = l_val;
cell->fragment_id = get_attr_val(t_attr, "id", html_context->options);
cell->fragment_id = get_attr_val(t_attr, "id", html_context->options->cp);
if (!cell->fragment_id && l_fragment_id) {
cell->fragment_id = l_fragment_id;
l_fragment_id = NULL;
@ -812,12 +812,12 @@ see:
get_valign(html_context, t_attr, &cell->valign);
get_bgcolor(html_context, t_attr, &cell->bgcolor);
colspan = get_num(t_attr, "colspan", html_context->options);
colspan = get_num(t_attr, "colspan", html_context->options->cp);
if (colspan == -1) colspan = 1;
else if (!colspan) colspan = -1;
else if (colspan > HTML_MAX_COLSPAN) colspan = HTML_MAX_COLSPAN;
rowspan = get_num(t_attr, "rowspan", html_context->options);
rowspan = get_num(t_attr, "rowspan", html_context->options->cp);
if (rowspan == -1) rowspan = 1;
else if (!rowspan) rowspan = -1;
else if (rowspan > HTML_MAX_ROWSPAN) rowspan = HTML_MAX_ROWSPAN;