Gitweb links:
...log
http://git.netsurf-browser.org/netsurf.git/shortlog/1776a0e61e7e52c9e366103f7af129d1fc554fdb
...commit
http://git.netsurf-browser.org/netsurf.git/commit/1776a0e61e7e52c9e366103f7af129d1fc554fdb
...tree
http://git.netsurf-browser.org/netsurf.git/tree/1776a0e61e7e52c9e366103f7af129d1fc554fdb
The branch, master has been updated
via 1776a0e61e7e52c9e366103f7af129d1fc554fdb (commit)
via 6efe60ee1d00d61362a52c92b2c6404b88321769 (commit)
via 17de8d91ac51f487a8a7fc95bd9fc5edfd2d30cc (commit)
from 11d2921bbfca6c00ec1d68bdb6ddd25beacbec3d (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=1776a0e61e7e52c9e366103f7af129d1fc554fdb
commit 1776a0e61e7e52c9e366103f7af129d1fc554fdb
Author: Vincent Sanders <[email protected]>
Commit: Vincent Sanders <[email protected]>
make box construction use correct ascii processing
diff --git a/render/box_construct.c b/render/box_construct.c
index f9e7178..f6f18ab 100644
--- a/render/box_construct.c
+++ b/render/box_construct.c
@@ -26,7 +26,6 @@
*/
#include <assert.h>
-#include <ctype.h>
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
@@ -42,6 +41,7 @@
#include "utils/talloc.h"
#include "utils/utils.h"
#include "utils/string.h"
+#include "utils/ascii.h"
#include "content/content_protected.h"
#include "css/hints.h"
#include "css/select.h"
@@ -128,8 +128,6 @@ static bool box_pre(BOX_SPECIAL_PARAMS);
static bool box_iframe(BOX_SPECIAL_PARAMS);
static bool box_get_attribute(dom_node *n, const char *attribute,
void *context, char **value);
-static struct frame_dimension *box_parse_multi_lengths(const char *s,
- unsigned int *count);
/* element_table must be sorted by name */
struct element_entry {
@@ -1939,6 +1937,65 @@ static int box_frames_talloc_destructor(struct
content_html_frames *f)
return 0;
}
+
+/**
+ * Parse a multi-length-list, as defined by HTML 4.01.
+ *
+ * \param ds dom string to parse
+ * \param count updated to number of entries
+ * \return array of struct box_multi_length, or 0 on memory exhaustion
+ */
+static struct frame_dimension *
+box_parse_multi_lengths(const dom_string *ds, unsigned int *count)
+{
+ char *end;
+ unsigned int i, n;
+ struct frame_dimension *length;
+ const char *s;
+
+ s = dom_string_data(ds);
+
+ for (i = 0, n = 1; s[i]; i++)
+ if (s[i] == ',')
+ n++;
+
+ length = calloc(n, sizeof(struct frame_dimension));
+ if (!length)
+ return NULL;
+
+ for (i = 0; i != n; i++) {
+ while (ascii_is_space(*s)) {
+ s++;
+ }
+ length[i].value = strtof(s, &end);
+ if (length[i].value <= 0) {
+ length[i].value = 1;
+ }
+ s = end;
+ switch (*s) {
+ case '%':
+ length[i].unit = FRAME_DIMENSION_PERCENT;
+ break;
+ case '*':
+ length[i].unit = FRAME_DIMENSION_RELATIVE;
+ break;
+ default:
+ length[i].unit = FRAME_DIMENSION_PIXELS;
+ break;
+ }
+ while (*s && *s != ',') {
+ s++;
+ }
+ if (*s == ',') {
+ s++;
+ }
+ }
+
+ *count = n;
+ return length;
+}
+
+
bool box_create_frameset(struct content_html_frames *f, dom_node *n,
html_content *content) {
unsigned int row, col, index, i;
@@ -1955,7 +2012,7 @@ bool box_create_frameset(struct content_html_frames *f,
dom_node *n,
/* parse rows and columns */
err = dom_element_get_attribute(n, corestring_dom_rows, &s);
if (err == DOM_NO_ERR && s != NULL) {
- row_height = box_parse_multi_lengths(dom_string_data(s), &rows);
+ row_height = box_parse_multi_lengths(s, &rows);
dom_string_unref(s);
if (row_height == NULL)
return false;
@@ -1969,7 +2026,7 @@ bool box_create_frameset(struct content_html_frames *f,
dom_node *n,
err = dom_element_get_attribute(n, corestring_dom_cols, &s);
if (err == DOM_NO_ERR && s != NULL) {
- col_width = box_parse_multi_lengths(dom_string_data(s), &cols);
+ col_width = box_parse_multi_lengths(s, &cols);
dom_string_unref(s);
if (col_width == NULL) {
free(row_height);
@@ -3012,9 +3069,11 @@ box_extract_link(const html_content *content,
return false;
/* copy to s, removing white space and control characters */
- for (i = 0; rel[i] && isspace(rel[i]); i++)
+ for (i = 0; rel[i] && ascii_is_space(rel[i]); i++)
;
- for (end = strlen(rel); end != i && isspace(rel[end - 1]); end--)
+ for (end = strlen(rel);
+ (end != i) && ascii_is_space(rel[end - 1]);
+ end--)
;
for (j = 0; i != end; i++) {
if ((unsigned char) rel[i] < 0x20) {
@@ -3061,54 +3120,4 @@ box_extract_link(const html_content *content,
}
-/**
- * Parse a multi-length-list, as defined by HTML 4.01.
- *
- * \param s string to parse
- * \param count updated to number of entries
- * \return array of struct box_multi_length, or 0 on memory exhaustion
- */
-
-struct frame_dimension *box_parse_multi_lengths(const char *s,
- unsigned int *count)
-{
- char *end;
- unsigned int i, n;
- struct frame_dimension *length;
-
- for (i = 0, n = 1; s[i]; i++)
- if (s[i] == ',')
- n++;
-
- length = calloc(n, sizeof(struct frame_dimension));
- if (!length)
- return NULL;
-
- for (i = 0; i != n; i++) {
- while (isspace(*s))
- s++;
- length[i].value = strtof(s, &end);
- if (length[i].value <= 0)
- length[i].value = 1;
- s = end;
- switch (*s) {
- case '%':
- length[i].unit = FRAME_DIMENSION_PERCENT;
- break;
- case '*':
- length[i].unit = FRAME_DIMENSION_RELATIVE;
- break;
- default:
- length[i].unit = FRAME_DIMENSION_PIXELS;
- break;
- }
- while (*s && *s != ',')
- s++;
- if (*s == ',')
- s++;
- }
-
- *count = n;
- return length;
-}
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=6efe60ee1d00d61362a52c92b2c6404b88321769
commit 6efe60ee1d00d61362a52c92b2c6404b88321769
Author: Vincent Sanders <[email protected]>
Commit: Vincent Sanders <[email protected]>
simplify box_extract_link interface and improve documentation
diff --git a/render/box.h b/render/box.h
index c3f95c2..79ff44d 100644
--- a/render/box.h
+++ b/render/box.h
@@ -100,6 +100,7 @@ struct object_param;
struct html_content;
struct nsurl;
struct dom_node;
+struct dom_string;
struct rect;
#define UNKNOWN_WIDTH INT_MAX
@@ -334,8 +335,18 @@ struct box *box_pick_text_box(struct html_content *html,
struct box *box_find_by_id(struct box *box, lwc_string *id);
bool box_visible(struct box *box);
void box_dump(FILE *stream, struct box *box, unsigned int depth, bool style);
-bool box_extract_link(const struct html_content *content,
- const char *rel, struct nsurl *base, struct nsurl **result);
+
+/**
+ * Extract a URL from a relative link, handling junk like whitespace and
+ * attempting to read a real URL from "javascript:" links.
+ *
+ * \param content html content
+ * \param ds rel relative URL text taken from page
+ * \param base base for relative URLs
+ * \param result updated to target URL on heap, unchanged if extract failed
+ * \return true on success, false on memory exhaustion
+ */
+bool box_extract_link(const struct html_content *content, const struct
dom_string *dsrel, struct nsurl *base, struct nsurl **result);
bool box_handle_scrollbars(struct content *c, struct box *box,
bool bottom, bool right);
diff --git a/render/box_construct.c b/render/box_construct.c
index 49bb794..f9e7178 100644
--- a/render/box_construct.c
+++ b/render/box_construct.c
@@ -1479,8 +1479,7 @@ bool box_a(BOX_SPECIAL_PARAMS)
err = dom_element_get_attribute(n, corestring_dom_href, &s);
if (err == DOM_NO_ERR && s != NULL) {
- ok = box_extract_link(content, dom_string_data(s),
- content->base_url, &url);
+ ok = box_extract_link(content, s, content->base_url, &url);
dom_string_unref(s);
if (!ok)
return false;
@@ -1593,8 +1592,7 @@ bool box_image(BOX_SPECIAL_PARAMS)
if (err != DOM_NO_ERR || s == NULL)
return true;
- if (box_extract_link(content, dom_string_data(s), content->base_url,
- &url) == false) {
+ if (box_extract_link(content, s, content->base_url, &url) == false) {
dom_string_unref(s);
return false;
}
@@ -1695,8 +1693,7 @@ bool box_object(BOX_SPECIAL_PARAMS)
* (codebase is the base for the other two) */
err = dom_element_get_attribute(n, corestring_dom_codebase, &codebase);
if (err == DOM_NO_ERR && codebase != NULL) {
- if (box_extract_link(content, dom_string_data(codebase),
- content->base_url,
+ if (box_extract_link(content, codebase, content->base_url,
¶ms->codebase) == false) {
dom_string_unref(codebase);
return false;
@@ -1708,7 +1705,7 @@ bool box_object(BOX_SPECIAL_PARAMS)
err = dom_element_get_attribute(n, corestring_dom_classid, &classid);
if (err == DOM_NO_ERR && classid != NULL) {
- if (box_extract_link(content, dom_string_data(classid),
+ if (box_extract_link(content, classid,
params->codebase, ¶ms->classid) == false) {
dom_string_unref(classid);
return false;
@@ -1718,7 +1715,7 @@ bool box_object(BOX_SPECIAL_PARAMS)
err = dom_element_get_attribute(n, corestring_dom_data, &data);
if (err == DOM_NO_ERR && data != NULL) {
- if (box_extract_link(content, dom_string_data(data),
+ if (box_extract_link(content, data,
params->codebase, ¶ms->data) == false) {
dom_string_unref(data);
return false;
@@ -2139,8 +2136,8 @@ bool box_create_frameset(struct content_html_frames *f,
dom_node *n,
url = NULL;
err = dom_element_get_attribute(c, corestring_dom_src,
&s);
if (err == DOM_NO_ERR && s != NULL) {
- box_extract_link(content, dom_string_data(s),
- content->base_url, &url);
+ box_extract_link(content, s, content->base_url,
+ &url);
dom_string_unref(s);
}
@@ -2275,8 +2272,7 @@ bool box_iframe(BOX_SPECIAL_PARAMS)
err = dom_element_get_attribute(n, corestring_dom_src, &s);
if (err != DOM_NO_ERR || s == NULL)
return true;
- if (box_extract_link(content, dom_string_data(s), content->base_url,
- &url) == false) {
+ if (box_extract_link(content, s, content->base_url, &url) == false) {
dom_string_unref(s);
return false;
}
@@ -2853,8 +2849,8 @@ bool box_embed(BOX_SPECIAL_PARAMS)
err = dom_element_get_attribute(n, corestring_dom_src, &src);
if (err != DOM_NO_ERR || src == NULL)
return true;
- if (box_extract_link(content, dom_string_data(src), content->base_url,
- ¶ms->data) == false) {
+ if (box_extract_link(content, src, content->base_url,
+ ¶ms->data) == false) {
dom_string_unref(src);
return false;
}
@@ -2997,22 +2993,19 @@ bool box_get_attribute(dom_node *n, const char
*attribute,
}
-/**
- * Extract a URL from a relative link, handling junk like whitespace and
- * attempting to read a real URL from "javascript:" links.
- *
- * \param rel relative URL taken from page
- * \param base base for relative URLs
- * \param result updated to target URL on heap, unchanged if extract failed
- * \return true on success, false on memory exhaustion
- */
-
-bool box_extract_link(const html_content *content,
- const char *rel, nsurl *base, nsurl **result)
+/* exported function documented in render/box.h */
+bool
+box_extract_link(const html_content *content,
+ const dom_string *dsrel,
+ nsurl *base,
+ nsurl **result)
{
char *s, *s1, *apos0 = 0, *apos1 = 0, *quot0 = 0, *quot1 = 0;
unsigned int i, j, end;
nserror error;
+ const char *rel;
+
+ rel = dom_string_data(dsrel);
s1 = s = malloc(3 * strlen(rel) + 1);
if (!s)
diff --git a/render/imagemap.c b/render/imagemap.c
index b1cb824..10b48f1 100644
--- a/render/imagemap.c
+++ b/render/imagemap.c
@@ -347,8 +347,7 @@ imagemap_addtolist(const struct html_content *c, dom_node
*n, nsurl *base_url,
else
goto bad_out;
- if (box_extract_link(c, dom_string_data(href),
- base_url, &new_map->url) == false)
+ if (box_extract_link(c, href, base_url, &new_map->url) == false)
goto bad_out;
if (new_map->url == NULL) {
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=17de8d91ac51f487a8a7fc95bd9fc5edfd2d30cc
commit 17de8d91ac51f487a8a7fc95bd9fc5edfd2d30cc
Author: Vincent Sanders <[email protected]>
Commit: Vincent Sanders <[email protected]>
change save complete to use ascii character manipulation
diff --git a/desktop/save_complete.c b/desktop/save_complete.c
index 314fbfc..f8f0057 100644
--- a/desktop/save_complete.c
+++ b/desktop/save_complete.c
@@ -23,7 +23,6 @@
*/
#include <assert.h>
-#include <ctype.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
@@ -40,6 +39,7 @@
#include "utils/utils.h"
#include "utils/file.h"
#include "utils/messages.h"
+#include "utils/ascii.h"
#include "netsurf/content.h"
#include "content/hlcache.h"
#include "css/css.h"
@@ -210,13 +210,14 @@ static char
*save_complete_rewrite_stylesheet_urls(save_complete_ctx *ctx,
for (offset = 0; SLEN("@import") < size &&
offset <= size - SLEN("@import"); offset++) {
if (source[offset] == '@' &&
- tolower(source[offset + 1]) == 'i' &&
- tolower(source[offset + 2]) == 'm' &&
- tolower(source[offset + 3]) == 'p' &&
- tolower(source[offset + 4]) == 'o' &&
- tolower(source[offset + 5]) == 'r' &&
- tolower(source[offset + 6]) == 't')
+ ascii_to_lower(source[offset + 1]) == 'i' &&
+ ascii_to_lower(source[offset + 2]) == 'm' &&
+ ascii_to_lower(source[offset + 3]) == 'p' &&
+ ascii_to_lower(source[offset + 4]) == 'o' &&
+ ascii_to_lower(source[offset + 5]) == 'r' &&
+ ascii_to_lower(source[offset + 6]) == 't') {
imports++;
+ }
}
rewritten = malloc(size + imports * 20);
-----------------------------------------------------------------------
Summary of changes:
desktop/save_complete.c | 15 +++--
render/box.h | 15 ++++-
render/box_construct.c | 168 ++++++++++++++++++++++++-----------------------
render/imagemap.c | 3 +-
4 files changed, 107 insertions(+), 94 deletions(-)
diff --git a/desktop/save_complete.c b/desktop/save_complete.c
index 314fbfc..f8f0057 100644
--- a/desktop/save_complete.c
+++ b/desktop/save_complete.c
@@ -23,7 +23,6 @@
*/
#include <assert.h>
-#include <ctype.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
@@ -40,6 +39,7 @@
#include "utils/utils.h"
#include "utils/file.h"
#include "utils/messages.h"
+#include "utils/ascii.h"
#include "netsurf/content.h"
#include "content/hlcache.h"
#include "css/css.h"
@@ -210,13 +210,14 @@ static char
*save_complete_rewrite_stylesheet_urls(save_complete_ctx *ctx,
for (offset = 0; SLEN("@import") < size &&
offset <= size - SLEN("@import"); offset++) {
if (source[offset] == '@' &&
- tolower(source[offset + 1]) == 'i' &&
- tolower(source[offset + 2]) == 'm' &&
- tolower(source[offset + 3]) == 'p' &&
- tolower(source[offset + 4]) == 'o' &&
- tolower(source[offset + 5]) == 'r' &&
- tolower(source[offset + 6]) == 't')
+ ascii_to_lower(source[offset + 1]) == 'i' &&
+ ascii_to_lower(source[offset + 2]) == 'm' &&
+ ascii_to_lower(source[offset + 3]) == 'p' &&
+ ascii_to_lower(source[offset + 4]) == 'o' &&
+ ascii_to_lower(source[offset + 5]) == 'r' &&
+ ascii_to_lower(source[offset + 6]) == 't') {
imports++;
+ }
}
rewritten = malloc(size + imports * 20);
diff --git a/render/box.h b/render/box.h
index c3f95c2..79ff44d 100644
--- a/render/box.h
+++ b/render/box.h
@@ -100,6 +100,7 @@ struct object_param;
struct html_content;
struct nsurl;
struct dom_node;
+struct dom_string;
struct rect;
#define UNKNOWN_WIDTH INT_MAX
@@ -334,8 +335,18 @@ struct box *box_pick_text_box(struct html_content *html,
struct box *box_find_by_id(struct box *box, lwc_string *id);
bool box_visible(struct box *box);
void box_dump(FILE *stream, struct box *box, unsigned int depth, bool style);
-bool box_extract_link(const struct html_content *content,
- const char *rel, struct nsurl *base, struct nsurl **result);
+
+/**
+ * Extract a URL from a relative link, handling junk like whitespace and
+ * attempting to read a real URL from "javascript:" links.
+ *
+ * \param content html content
+ * \param ds rel relative URL text taken from page
+ * \param base base for relative URLs
+ * \param result updated to target URL on heap, unchanged if extract failed
+ * \return true on success, false on memory exhaustion
+ */
+bool box_extract_link(const struct html_content *content, const struct
dom_string *dsrel, struct nsurl *base, struct nsurl **result);
bool box_handle_scrollbars(struct content *c, struct box *box,
bool bottom, bool right);
diff --git a/render/box_construct.c b/render/box_construct.c
index 49bb794..f6f18ab 100644
--- a/render/box_construct.c
+++ b/render/box_construct.c
@@ -26,7 +26,6 @@
*/
#include <assert.h>
-#include <ctype.h>
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
@@ -42,6 +41,7 @@
#include "utils/talloc.h"
#include "utils/utils.h"
#include "utils/string.h"
+#include "utils/ascii.h"
#include "content/content_protected.h"
#include "css/hints.h"
#include "css/select.h"
@@ -128,8 +128,6 @@ static bool box_pre(BOX_SPECIAL_PARAMS);
static bool box_iframe(BOX_SPECIAL_PARAMS);
static bool box_get_attribute(dom_node *n, const char *attribute,
void *context, char **value);
-static struct frame_dimension *box_parse_multi_lengths(const char *s,
- unsigned int *count);
/* element_table must be sorted by name */
struct element_entry {
@@ -1479,8 +1477,7 @@ bool box_a(BOX_SPECIAL_PARAMS)
err = dom_element_get_attribute(n, corestring_dom_href, &s);
if (err == DOM_NO_ERR && s != NULL) {
- ok = box_extract_link(content, dom_string_data(s),
- content->base_url, &url);
+ ok = box_extract_link(content, s, content->base_url, &url);
dom_string_unref(s);
if (!ok)
return false;
@@ -1593,8 +1590,7 @@ bool box_image(BOX_SPECIAL_PARAMS)
if (err != DOM_NO_ERR || s == NULL)
return true;
- if (box_extract_link(content, dom_string_data(s), content->base_url,
- &url) == false) {
+ if (box_extract_link(content, s, content->base_url, &url) == false) {
dom_string_unref(s);
return false;
}
@@ -1695,8 +1691,7 @@ bool box_object(BOX_SPECIAL_PARAMS)
* (codebase is the base for the other two) */
err = dom_element_get_attribute(n, corestring_dom_codebase, &codebase);
if (err == DOM_NO_ERR && codebase != NULL) {
- if (box_extract_link(content, dom_string_data(codebase),
- content->base_url,
+ if (box_extract_link(content, codebase, content->base_url,
¶ms->codebase) == false) {
dom_string_unref(codebase);
return false;
@@ -1708,7 +1703,7 @@ bool box_object(BOX_SPECIAL_PARAMS)
err = dom_element_get_attribute(n, corestring_dom_classid, &classid);
if (err == DOM_NO_ERR && classid != NULL) {
- if (box_extract_link(content, dom_string_data(classid),
+ if (box_extract_link(content, classid,
params->codebase, ¶ms->classid) == false) {
dom_string_unref(classid);
return false;
@@ -1718,7 +1713,7 @@ bool box_object(BOX_SPECIAL_PARAMS)
err = dom_element_get_attribute(n, corestring_dom_data, &data);
if (err == DOM_NO_ERR && data != NULL) {
- if (box_extract_link(content, dom_string_data(data),
+ if (box_extract_link(content, data,
params->codebase, ¶ms->data) == false) {
dom_string_unref(data);
return false;
@@ -1942,6 +1937,65 @@ static int box_frames_talloc_destructor(struct
content_html_frames *f)
return 0;
}
+
+/**
+ * Parse a multi-length-list, as defined by HTML 4.01.
+ *
+ * \param ds dom string to parse
+ * \param count updated to number of entries
+ * \return array of struct box_multi_length, or 0 on memory exhaustion
+ */
+static struct frame_dimension *
+box_parse_multi_lengths(const dom_string *ds, unsigned int *count)
+{
+ char *end;
+ unsigned int i, n;
+ struct frame_dimension *length;
+ const char *s;
+
+ s = dom_string_data(ds);
+
+ for (i = 0, n = 1; s[i]; i++)
+ if (s[i] == ',')
+ n++;
+
+ length = calloc(n, sizeof(struct frame_dimension));
+ if (!length)
+ return NULL;
+
+ for (i = 0; i != n; i++) {
+ while (ascii_is_space(*s)) {
+ s++;
+ }
+ length[i].value = strtof(s, &end);
+ if (length[i].value <= 0) {
+ length[i].value = 1;
+ }
+ s = end;
+ switch (*s) {
+ case '%':
+ length[i].unit = FRAME_DIMENSION_PERCENT;
+ break;
+ case '*':
+ length[i].unit = FRAME_DIMENSION_RELATIVE;
+ break;
+ default:
+ length[i].unit = FRAME_DIMENSION_PIXELS;
+ break;
+ }
+ while (*s && *s != ',') {
+ s++;
+ }
+ if (*s == ',') {
+ s++;
+ }
+ }
+
+ *count = n;
+ return length;
+}
+
+
bool box_create_frameset(struct content_html_frames *f, dom_node *n,
html_content *content) {
unsigned int row, col, index, i;
@@ -1958,7 +2012,7 @@ bool box_create_frameset(struct content_html_frames *f,
dom_node *n,
/* parse rows and columns */
err = dom_element_get_attribute(n, corestring_dom_rows, &s);
if (err == DOM_NO_ERR && s != NULL) {
- row_height = box_parse_multi_lengths(dom_string_data(s), &rows);
+ row_height = box_parse_multi_lengths(s, &rows);
dom_string_unref(s);
if (row_height == NULL)
return false;
@@ -1972,7 +2026,7 @@ bool box_create_frameset(struct content_html_frames *f,
dom_node *n,
err = dom_element_get_attribute(n, corestring_dom_cols, &s);
if (err == DOM_NO_ERR && s != NULL) {
- col_width = box_parse_multi_lengths(dom_string_data(s), &cols);
+ col_width = box_parse_multi_lengths(s, &cols);
dom_string_unref(s);
if (col_width == NULL) {
free(row_height);
@@ -2139,8 +2193,8 @@ bool box_create_frameset(struct content_html_frames *f,
dom_node *n,
url = NULL;
err = dom_element_get_attribute(c, corestring_dom_src,
&s);
if (err == DOM_NO_ERR && s != NULL) {
- box_extract_link(content, dom_string_data(s),
- content->base_url, &url);
+ box_extract_link(content, s, content->base_url,
+ &url);
dom_string_unref(s);
}
@@ -2275,8 +2329,7 @@ bool box_iframe(BOX_SPECIAL_PARAMS)
err = dom_element_get_attribute(n, corestring_dom_src, &s);
if (err != DOM_NO_ERR || s == NULL)
return true;
- if (box_extract_link(content, dom_string_data(s), content->base_url,
- &url) == false) {
+ if (box_extract_link(content, s, content->base_url, &url) == false) {
dom_string_unref(s);
return false;
}
@@ -2853,8 +2906,8 @@ bool box_embed(BOX_SPECIAL_PARAMS)
err = dom_element_get_attribute(n, corestring_dom_src, &src);
if (err != DOM_NO_ERR || src == NULL)
return true;
- if (box_extract_link(content, dom_string_data(src), content->base_url,
- ¶ms->data) == false) {
+ if (box_extract_link(content, src, content->base_url,
+ ¶ms->data) == false) {
dom_string_unref(src);
return false;
}
@@ -2997,31 +3050,30 @@ bool box_get_attribute(dom_node *n, const char
*attribute,
}
-/**
- * Extract a URL from a relative link, handling junk like whitespace and
- * attempting to read a real URL from "javascript:" links.
- *
- * \param rel relative URL taken from page
- * \param base base for relative URLs
- * \param result updated to target URL on heap, unchanged if extract failed
- * \return true on success, false on memory exhaustion
- */
-
-bool box_extract_link(const html_content *content,
- const char *rel, nsurl *base, nsurl **result)
+/* exported function documented in render/box.h */
+bool
+box_extract_link(const html_content *content,
+ const dom_string *dsrel,
+ nsurl *base,
+ nsurl **result)
{
char *s, *s1, *apos0 = 0, *apos1 = 0, *quot0 = 0, *quot1 = 0;
unsigned int i, j, end;
nserror error;
+ const char *rel;
+
+ rel = dom_string_data(dsrel);
s1 = s = malloc(3 * strlen(rel) + 1);
if (!s)
return false;
/* copy to s, removing white space and control characters */
- for (i = 0; rel[i] && isspace(rel[i]); i++)
+ for (i = 0; rel[i] && ascii_is_space(rel[i]); i++)
;
- for (end = strlen(rel); end != i && isspace(rel[end - 1]); end--)
+ for (end = strlen(rel);
+ (end != i) && ascii_is_space(rel[end - 1]);
+ end--)
;
for (j = 0; i != end; i++) {
if ((unsigned char) rel[i] < 0x20) {
@@ -3068,54 +3120,4 @@ bool box_extract_link(const html_content *content,
}
-/**
- * Parse a multi-length-list, as defined by HTML 4.01.
- *
- * \param s string to parse
- * \param count updated to number of entries
- * \return array of struct box_multi_length, or 0 on memory exhaustion
- */
-
-struct frame_dimension *box_parse_multi_lengths(const char *s,
- unsigned int *count)
-{
- char *end;
- unsigned int i, n;
- struct frame_dimension *length;
-
- for (i = 0, n = 1; s[i]; i++)
- if (s[i] == ',')
- n++;
-
- length = calloc(n, sizeof(struct frame_dimension));
- if (!length)
- return NULL;
-
- for (i = 0; i != n; i++) {
- while (isspace(*s))
- s++;
- length[i].value = strtof(s, &end);
- if (length[i].value <= 0)
- length[i].value = 1;
- s = end;
- switch (*s) {
- case '%':
- length[i].unit = FRAME_DIMENSION_PERCENT;
- break;
- case '*':
- length[i].unit = FRAME_DIMENSION_RELATIVE;
- break;
- default:
- length[i].unit = FRAME_DIMENSION_PIXELS;
- break;
- }
- while (*s && *s != ',')
- s++;
- if (*s == ',')
- s++;
- }
-
- *count = n;
- return length;
-}
diff --git a/render/imagemap.c b/render/imagemap.c
index b1cb824..10b48f1 100644
--- a/render/imagemap.c
+++ b/render/imagemap.c
@@ -347,8 +347,7 @@ imagemap_addtolist(const struct html_content *c, dom_node
*n, nsurl *base_url,
else
goto bad_out;
- if (box_extract_link(c, dom_string_data(href),
- base_url, &new_map->url) == false)
+ if (box_extract_link(c, href, base_url, &new_map->url) == false)
goto bad_out;
if (new_map->url == NULL) {
--
NetSurf Browser
_______________________________________________
netsurf-commits mailing list
[email protected]
http://listmaster.pepperfish.net/cgi-bin/mailman/listinfo/netsurf-commits-netsurf-browser.org