mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-12-22 20:16:54 +03:00
Use correct base URL for inline stylesheets
This commit is contained in:
parent
cd3e073354
commit
6b9f7c3094
10
css/css.c
10
css/css.c
@ -129,6 +129,7 @@ nserror nscss_create(const content_handler *handler,
|
||||
{
|
||||
nscss_content *result;
|
||||
const char *charset = NULL;
|
||||
const char *xnsbase = NULL;
|
||||
lwc_string *charset_value = NULL;
|
||||
union content_msg_data msg_data;
|
||||
nserror error;
|
||||
@ -155,9 +156,14 @@ nserror nscss_create(const content_handler *handler,
|
||||
charset = lwc_string_data(charset_value);
|
||||
}
|
||||
|
||||
/* Compute base URL for stylesheet */
|
||||
xnsbase = llcache_handle_get_header(llcache, "X-NS-Base");
|
||||
if (xnsbase == NULL) {
|
||||
xnsbase = nsurl_access(content_get_url(&result->base));
|
||||
}
|
||||
|
||||
error = nscss_create_css_data(&result->data,
|
||||
nsurl_access(content_get_url(&result->base)),
|
||||
charset, result->base.quirks,
|
||||
xnsbase, charset, result->base.quirks,
|
||||
nscss_content_done, result);
|
||||
if (error != NSERROR_OK) {
|
||||
msg_data.error = messages_get("NoMemory");
|
||||
|
@ -296,7 +296,7 @@ html_stylesheet_from_domnode(html_content *c,
|
||||
return NSERROR_OK;
|
||||
}
|
||||
|
||||
error = html_css_fetcher_add_item(style, &key);
|
||||
error = html_css_fetcher_add_item(style, c->base_url, &key);
|
||||
if (error != NSERROR_OK) {
|
||||
dom_string_unref(style);
|
||||
return error;
|
||||
|
@ -37,6 +37,7 @@
|
||||
typedef struct html_css_fetcher_item {
|
||||
uint32_t key;
|
||||
dom_string *data;
|
||||
nsurl *base_url;
|
||||
|
||||
struct html_css_fetcher_item *r_next, *r_prev;
|
||||
} html_css_fetcher_item;
|
||||
@ -142,6 +143,7 @@ static void html_css_fetcher_free(void *ctx)
|
||||
|
||||
nsurl_unref(c->url);
|
||||
if (c->item != NULL) {
|
||||
nsurl_unref(c->item->base_url);
|
||||
dom_string_unref(c->item->data);
|
||||
RING_REMOVE(items, c->item);
|
||||
free(c->item);
|
||||
@ -195,7 +197,7 @@ static void html_css_fetcher_poll(lwc_string *scheme)
|
||||
/* Nothing to do */
|
||||
assert(c->locked == false);
|
||||
} else if (c->item != NULL) {
|
||||
char header[64];
|
||||
char header[4096];
|
||||
|
||||
fetch_set_http_code(c->parent_fetch, 200);
|
||||
|
||||
@ -221,6 +223,18 @@ static void html_css_fetcher_poll(lwc_string *scheme)
|
||||
html_css_fetcher_send_callback(&msg, c);
|
||||
}
|
||||
|
||||
if (c->aborted == false) {
|
||||
snprintf(header, sizeof header,
|
||||
"X-NS-Base: %.*s",
|
||||
(int) nsurl_length(c->item->base_url),
|
||||
nsurl_access(c->item->base_url));
|
||||
msg.type = FETCH_HEADER;
|
||||
msg.data.header_or_data.buf =
|
||||
(const uint8_t *) header;
|
||||
msg.data.header_or_data.len = strlen(header);
|
||||
html_css_fetcher_send_callback(&msg, c);
|
||||
}
|
||||
|
||||
if (c->aborted == false) {
|
||||
msg.type = FETCH_DATA;
|
||||
msg.data.header_or_data.buf =
|
||||
@ -280,7 +294,8 @@ void html_css_fetcher_register(void)
|
||||
html_css_fetcher_finalise);
|
||||
}
|
||||
|
||||
nserror html_css_fetcher_add_item(dom_string *data, uint32_t *key)
|
||||
nserror html_css_fetcher_add_item(dom_string *data, nsurl *base_url,
|
||||
uint32_t *key)
|
||||
{
|
||||
html_css_fetcher_item *item = malloc(sizeof(*item));
|
||||
|
||||
@ -290,6 +305,7 @@ nserror html_css_fetcher_add_item(dom_string *data, uint32_t *key)
|
||||
|
||||
*key = item->key = current_key++;
|
||||
item->data = dom_string_ref(data);
|
||||
item->base_url = nsurl_ref(base_url);
|
||||
|
||||
RING_INSERT(items, item);
|
||||
|
||||
|
@ -268,11 +268,13 @@ nserror html_css_free_stylesheets(html_content *html);
|
||||
bool html_css_process_link(html_content *htmlc, dom_node *node);
|
||||
bool html_css_update_style(html_content *c, dom_node *style);
|
||||
|
||||
nserror html_css_new_selection_context(html_content *c, css_select_ctx **ret_select_ctx);
|
||||
nserror html_css_new_selection_context(html_content *c,
|
||||
css_select_ctx **ret_select_ctx);
|
||||
|
||||
/* in render/html_css_fetcher.c */
|
||||
void html_css_fetcher_register(void);
|
||||
nserror html_css_fetcher_add_item(dom_string *data, uint32_t *key);
|
||||
nserror html_css_fetcher_add_item(dom_string *data, nsurl *base_url,
|
||||
uint32_t *key);
|
||||
|
||||
/* in render/html_object.c */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user