1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-09-30 03:26:23 -04:00

Decode the fragment identifier extracted from the URI when looking it up

This fixes a problem with fragment references that was reported
by Thomas Adam.
This commit is contained in:
Miciah Dashiel Butler Masters 2006-12-05 18:04:53 +00:00 committed by Miciah Dashiel Butler Masters
parent d90702aeca
commit c22f38413e

View File

@ -47,30 +47,43 @@ check_document_fragment(struct session *ses, struct document_view *doc_view)
{
struct document *document = doc_view->document;
struct uri *uri = doc_view->vs->uri;
int vy = find_tag(document, uri->fragment, uri->fragmentlen);
int vy;
struct string fragment;
assert(uri->fragmentlen);
if (!init_string(&fragment)) return -2;
if (!add_uri_to_string(&fragment, uri, URI_FRAGMENT)) {
done_string(&fragment);
return -2;
}
decode_uri_string(&fragment);
assert(fragment.length);
assert(*fragment.source);
/* Omit the leading '#' when calling find_tag. */
vy = find_tag(document, fragment.source + 1, fragment.length - 1);
if (vy == -1) {
struct cache_entry *cached = find_in_cache(document->uri);
unsigned char *fragment;
if (!cached || cached->incomplete || cached->id != document->id)
if (!cached || cached->incomplete || cached->id != document->id) {
done_string(&fragment);
return -2;
fragment = memacpy(uri->fragment, uri->fragmentlen);
}
if (get_opt_bool("document.browse.links.missing_fragment")) {
info_box(ses->tab->term, MSGBOX_FREE_TEXT,
N_("Missing fragment"), ALIGN_CENTER,
msg_text(ses->tab->term, N_("The requested fragment "
"\"#%s\" doesn't exist."),
fragment));
"\"%s\" doesn't exist."),
fragment.source));
}
mem_free_if(fragment);
} else {
int_bounds(&vy, 0, document->height - 1);
}
done_string(&fragment);
return vy;
}