summaryrefslogtreecommitdiff
path: root/render
diff options
context:
space:
mode:
Diffstat (limited to 'render')
-rw-r--r--render/box.c67
-rw-r--r--render/html.c11
2 files changed, 46 insertions, 32 deletions
diff --git a/render/box.c b/render/box.c
index 32d643fb5..5776501b0 100644
--- a/render/box.c
+++ b/render/box.c
@@ -640,6 +640,7 @@ struct css_style * box_get_style(struct content *c,
struct css_style style_new;
char * s;
unsigned int i;
+ url_func_result res;
memcpy(style, parent_style, sizeof(struct css_style));
memcpy(&style_new, &css_blank_style, sizeof(struct css_style));
@@ -658,12 +659,12 @@ struct css_style * box_get_style(struct content *c,
if ((s = (char *) xmlGetProp(n, (const xmlChar *) "background"))) {
style->background_image.type = CSS_BACKGROUND_IMAGE_URI;
/**\todo This will leak memory. */
- style->background_image.uri = url_join(s, c->data.html.base_url);
+ res = url_join(s, c->data.html.base_url, &style->background_image.uri);
/* if url is equivalent to the parent's url,
* we've got infinite inclusion. stop it here.
* also bail if url_join failed.
*/
- if (!style->background_image.uri ||
+ if (res != URL_FUNC_OK ||
strcasecmp(style->background_image.uri, c->data.html.base_url) == 0)
style->background_image.type = CSS_BACKGROUND_IMAGE_NONE;
xmlFree(s);
@@ -897,6 +898,7 @@ struct box_result box_image(xmlNode *n, struct box_status *status,
struct box *box;
char *s, *url, *s1, *map;
xmlChar *s2;
+ url_func_result res;
box = box_create(style, status->href, status->title, status->id,
status->content->data.html.box_pool);
@@ -926,12 +928,12 @@ struct box_result box_image(xmlNode *n, struct box_status *status,
/* remove leading and trailing whitespace */
s1 = strip(s);
- url = url_join(s1, status->content->data.html.base_url);
+ res = url_join(s1, status->content->data.html.base_url, &url);
/* if url is equivalent to the parent's url,
* we've got infinite inclusion. stop it here.
* also bail if url_join failed.
*/
- if (!url ||
+ if (res != URL_FUNC_OK ||
strcasecmp(url, status->content->data.html.base_url) == 0) {
xmlFree(s);
return (struct box_result) {box, false, false};
@@ -1224,6 +1226,7 @@ struct box_result box_input(xmlNode *n, struct box_status *status,
struct box* box = NULL;
struct form_control *gadget = NULL;
char *s, *type, *url;
+ url_func_result res;
type = (char *) xmlGetProp(n, (const xmlChar *) "type");
@@ -1356,12 +1359,13 @@ struct box_result box_input(xmlNode *n, struct box_status *status,
gadget->box = box;
gadget->type = GADGET_IMAGE;
if ((s = (char *) xmlGetProp(n, (const xmlChar*) "src"))) {
- url = url_join(s, status->content->data.html.base_url);
+ res = url_join(s, status->content->data.html.base_url, &url);
/* if url is equivalent to the parent's url,
* we've got infinite inclusion. stop it here.
* also bail if url_join failed.
*/
- if (url && strcasecmp(url, status->content->data.html.base_url) != 0)
+ if (res == URL_FUNC_OK &&
+ strcasecmp(url, status->content->data.html.base_url) != 0)
html_fetch_object(status->content, url, box,
image_types,
status->content->available_width,
@@ -2049,6 +2053,7 @@ struct box_result box_object(xmlNode *n, struct box_status *status,
struct plugin_params* pp;
char *s, *url = NULL, *map;
xmlNode *c;
+ url_func_result res;
box = box_create(style, status->href, 0, status->id,
status->content->data.html.box_pool);
@@ -2065,12 +2070,12 @@ struct box_result box_object(xmlNode *n, struct box_status *status,
/* object data */
if ((s = (char *) xmlGetProp(n, (const xmlChar *) "data"))) {
- url = url_join(s, status->content->data.html.base_url);
+ res = url_join(s, status->content->data.html.base_url, &url);
/* if url is equivalent to the parent's url,
* we've got infinite inclusion. stop it here.
* also bail if url_join failed.
*/
- if (!url || strcasecmp(url, status->content->data.html.base_url) == 0) {
+ if (res != URL_FUNC_OK || strcasecmp(url, status->content->data.html.base_url) == 0) {
free(po);
xmlFree(s);
return (struct box_result) {box, true, true};
@@ -2193,6 +2198,7 @@ struct box_result box_embed(xmlNode *n, struct box_status *status,
struct plugin_params *pp;
char *s, *url = NULL;
xmlAttr *a;
+ url_func_result res;
box = box_create(style, status->href, 0, status->id,
status->content->data.html.box_pool);
@@ -2209,12 +2215,12 @@ struct box_result box_embed(xmlNode *n, struct box_status *status,
/* embed src */
if ((s = (char *) xmlGetProp(n, (const xmlChar *) "src"))) {
- url = url_join(s, status->content->data.html.base_url);
+ res = url_join(s, status->content->data.html.base_url, &url);
/* if url is equivalent to the parent's url,
* we've got infinite inclusion. stop it here.
* also bail if url_join failed.
*/
- if (!url || strcasecmp(url, status->content->data.html.base_url) == 0) {
+ if (res != URL_FUNC_OK || strcasecmp(url, status->content->data.html.base_url) == 0) {
free(po);
xmlFree(s);
return (struct box_result) {box, false, true};
@@ -2268,6 +2274,7 @@ struct box_result box_applet(xmlNode *n, struct box_status *status,
struct plugin_params *pp;
char *s, *url = NULL;
xmlNode *c;
+ url_func_result res;
box = box_create(style, status->href, 0, status->id,
status->content->data.html.box_pool);
@@ -2284,12 +2291,12 @@ struct box_result box_applet(xmlNode *n, struct box_status *status,
/* code */
if ((s = (char *) xmlGetProp(n, (const xmlChar *) "code"))) {
- url = url_join(s, status->content->data.html.base_url);
+ res = url_join(s, status->content->data.html.base_url, &url);
/* if url is equivalent to the parent's url,
* we've got infinite inclusion. stop it here.
* also bail if url_join failed.
*/
- if (!url || strcasecmp(url, status->content->data.html.base_url) == 0) {
+ if (res != URL_FUNC_OK || strcasecmp(url, status->content->data.html.base_url) == 0) {
free(po);
xmlFree(s);
return (struct box_result) {box, true, false};
@@ -2376,6 +2383,7 @@ struct box_result box_iframe(xmlNode *n, struct box_status *status,
struct box *box;
struct object_params *po;
char *s, *url = NULL;
+ url_func_result res;
box = box_create(style, status->href, 0, status->id,
status->content->data.html.box_pool);
@@ -2392,12 +2400,12 @@ struct box_result box_iframe(xmlNode *n, struct box_status *status,
/* iframe src */
if ((s = (char *) xmlGetProp(n, (const xmlChar *) "src"))) {
- url = url_join(s, status->content->data.html.base_url);
+ res = url_join(s, status->content->data.html.base_url, &url);
/* if url is equivalent to the parent's url,
* we've got infinite inclusion. stop it here.
* also bail if url_join failed.
*/
- if (!url || strcasecmp(url, status->content->data.html.base_url) == 0) {
+ if (res != URL_FUNC_OK || strcasecmp(url, status->content->data.html.base_url) == 0) {
free(po);
xmlFree(s);
return (struct box_result) {box, false, true};
@@ -2430,16 +2438,17 @@ bool plugin_decode(struct content* content, char* url, struct box* box,
struct object_params* po)
{
struct plugin_params * pp;
+ url_func_result res;
/* Check if the codebase attribute is defined.
* If it is not, set it to the codebase of the current document.
*/
if(po->codebase == 0)
- po->codebase = url_join("./", content->data.html.base_url);
+ res = url_join("./", content->data.html.base_url, &po->codebase);
else
- po->codebase = url_join(po->codebase, content->data.html.base_url);
+ res = url_join(po->codebase, content->data.html.base_url, &po->codebase);
- if (!po->codebase)
+ if (res != URL_FUNC_OK)
return false;
/* Set basehref */
@@ -2464,13 +2473,14 @@ bool plugin_decode(struct content* content, char* url, struct box* box,
pp = pp->next);
if(pp == 0)
return false;
- url = url_join(pp->value, po->basehref);
- if (!url)
+ res = url_join(pp->value, po->basehref, &url);
+ if (res != URL_FUNC_OK)
return false;
/* munge the codebase */
- po->codebase = url_join("./",
- content->data.html.base_url);
- if (!po->codebase)
+ res = url_join("./",
+ content->data.html.base_url,
+ &po->codebase);
+ if (res != URL_FUNC_OK)
return false;
}
else {
@@ -2479,8 +2489,8 @@ bool plugin_decode(struct content* content, char* url, struct box* box,
}
}
else {
- url = url_join(po->classid, po->codebase);
- if (!url)
+ res = url_join(po->classid, po->codebase, &url);
+ if (res != URL_FUNC_OK)
return false;
/* The java plugin doesn't need the .class extension
@@ -2492,8 +2502,8 @@ bool plugin_decode(struct content* content, char* url, struct box* box,
}
}
else {
- url = url_join(po->data, po->codebase);
- if (!url)
+ res = url_join(po->data, po->codebase, &url);
+ if (res != URL_FUNC_OK)
return false;
}
@@ -2537,6 +2547,7 @@ struct box_result box_frameset(xmlNode *n, struct box_status *status,
struct box_result r;
struct box_multi_length *row_height = 0, *col_width = 0;
xmlNode *c;
+ url_func_result res;
box = box_create(style, 0, status->title, status->id,
status->content->data.html.box_pool);
@@ -2676,12 +2687,12 @@ struct box_result box_frameset(xmlNode *n, struct box_status *status,
}
s1 = strip(s);
- url = url_join(s1, status->content->data.html.base_url);
+ res = url_join(s1, status->content->data.html.base_url, &url);
/* if url is equivalent to the parent's url,
* we've got infinite inclusion. stop it here.
* also bail if url_join failed.
*/
- if (!url || strcasecmp(url, status->content->data.html.base_url) == 0) {
+ if (res != URL_FUNC_OK || strcasecmp(url, status->content->data.html.base_url) == 0) {
xmlFree(s);
c = c->next;
continue;
diff --git a/render/html.c b/render/html.c
index 7bda3b02a..b19e99c30 100644
--- a/render/html.c
+++ b/render/html.c
@@ -304,8 +304,10 @@ void html_head(struct content *c, xmlNode *head)
} else if (strcmp(node->name, "base") == 0) {
char *href = (char *) xmlGetProp(node, (const xmlChar *) "href");
if (href) {
- char *url = url_normalize(href);
- if (url) {
+ char *url;
+ url_func_result res;
+ res = url_normalize(href, &url);
+ if (res == URL_FUNC_OK) {
free(c->data.html.base_url);
c->data.html.base_url = url;
}
@@ -330,6 +332,7 @@ void html_find_stylesheets(struct content *c, xmlNode *head)
unsigned int i = STYLESHEET_START;
unsigned int last_active = 0;
union content_msg_data msg_data;
+ url_func_result res;
/* stylesheet 0 is the base style sheet,
* stylesheet 1 is the adblocking stylesheet,
@@ -414,9 +417,9 @@ void html_find_stylesheets(struct content *c, xmlNode *head)
/* TODO: only the first preferred stylesheets (ie. those with a
* title attribute) should be loaded (see HTML4 14.3) */
- url = url_join(href, c->data.html.base_url);
+ res = url_join(href, c->data.html.base_url, &url);
xmlFree(href);
- if (!url)
+ if (res != URL_FUNC_OK)
continue;
LOG(("linked stylesheet %i '%s'", i, url));