r2961 rjek - /trunk/changemailer/genmail.lua
by netsurf@semichrome.net
Author: rjek
Date: Mon Sep 25 14:35:28 2006
New Revision: 2961
URL: http://svn.semichrome.net?rev=2961&view=rev
Log:
Update changemailer's HTML generator to only list changes since the last time it was run.
Modified:
trunk/changemailer/genmail.lua
Modified: trunk/changemailer/genmail.lua
URL: http://svn.semichrome.net/trunk/changemailer/genmail.lua?rev=2961&r1=2960...
==============================================================================
--- trunk/changemailer/genmail.lua (original)
+++ trunk/changemailer/genmail.lua Mon Sep 25 14:35:28 2006
@@ -5,9 +5,10 @@
-- This mail should then be sent by another cronjob.
-- Rob Kendrick <rjek(a)rjek.com> 2006-06-01
+local lastr = (io.open(arg[1] or error "Context file param missing", "r")
+ or error "Unable to open context file"):read("*l")
-local f = io.popen "svn log svn://semichrome.net/trunk/netsurf"
---local f = io.open("/home/rjek/nslog", "r")
+local f = io.popen("svn log -r ".. lastr + 1 ..":HEAD svn://semichrome.net/trunk/netsurf 2>&1")
local n = 0
local c = false -- true when we're processing the log text rather than the
-- change meta data
@@ -17,32 +18,42 @@
print "------------------------------------"
print "<p>Sorry, We've not had chance to annotate this week's changes.</p>"
print "Below are the changelog comments exported directly from Subversion."
-print "<ol>"
-repeat
- l = f:read("*l")
- if l == string.rep("-", 72) then
- -- start of new entry.
- n = n + 1
- if n > 1 then print "<br>" end
- c = false
- elseif l ~= nil then
- if not c then
- -- this is the log's meta data. parse it into more managable chunks
- local null, null, revision, author, time, messagelines =
- string.find(l, "^r([0-9]+) %| (%S+) %| (.+) %| (%S+).*$")
- print(string.format("<br><li>Change %s by %s:<br>",
- revision, author))
- c = true
- ml = 0
- else
- ml = ml + 1
- if ml ~= 1 then
- print(string.format("%s", l))
+l = f:read("*l")
+if string.find(l, "^svn%: No such revision") then
+ print "<p>There have been no changes since last week.</p>"
+else
+ print "<ol>"
+ repeat
+ if l == string.rep("-", 72) then
+ -- start of new entry.
+ n = n + 1
+ if n > 1 then print "<br>" end
+ c = false
+ elseif l ~= nil then
+ if not c then
+ -- this is the log's meta data. parse it into more managable chunks
+ local null, null, revision, author, time, date, messagelines =
+ string.find(l, "^r([0-9]+) %| (%S+) %| (.+) %((.+)%) %| (%S+).*$")
+ print(string.format("<br><li>Change %s by %s on %s:<br>",
+ revision, author, date))
+ c = true
+ ml = 0
+ else
+ ml = ml + 1
+ if ml ~= 1 then
+ print(string.format("%s", l))
+ end
end
end
- end
-until not l
+ l = f:read("*l")
+ until not l
+ print "</ol>"
+end
-print "</ol></body></html>"
+print "</body></html>"
+-- update the revision context file
+
+os.execute("svn info svn://semichrome.net/trunk/netsurf | grep ^Revision | sed -e's/Revision: //' > " .. arg[1])
+
16 years, 8 months
r2960 jmb - in /trunk/netsurf: render/form.c utils/url.c utils/url.h
by netsurf@semichrome.net
Author: jmb
Date: Tue Sep 19 11:08:33 2006
New Revision: 2960
URL: http://svn.semichrome.net?rev=2960&view=rev
Log:
Correcly encode spaces for url-encoded form submission.
Modified:
trunk/netsurf/render/form.c
trunk/netsurf/utils/url.c
trunk/netsurf/utils/url.h
Modified: trunk/netsurf/render/form.c
URL: http://svn.semichrome.net/trunk/netsurf/render/form.c?rev=2960&r1=2959&r2...
==============================================================================
--- trunk/netsurf/render/form.c (original)
+++ trunk/netsurf/render/form.c Tue Sep 19 11:08:33 2006
@@ -549,7 +549,7 @@
assert(err == UTF8_CONVERT_OK);
- url_err = url_escape(n_temp, &name);
+ url_err = url_escape(n_temp, true, &name);
if (url_err == URL_FUNC_NOMEM) {
free(v_temp);
free(n_temp);
@@ -560,7 +560,7 @@
assert(url_err == URL_FUNC_OK);
- url_err = url_escape(v_temp, &value);
+ url_err = url_escape(v_temp, true, &value);
if (url_err == URL_FUNC_NOMEM) {
free(name);
free(v_temp);
Modified: trunk/netsurf/utils/url.c
URL: http://svn.semichrome.net/trunk/netsurf/utils/url.c?rev=2960&r1=2959&r2=2...
==============================================================================
--- trunk/netsurf/utils/url.c (original)
+++ trunk/netsurf/utils/url.c Tue Sep 19 11:08:33 2006
@@ -236,8 +236,8 @@
assert(base);
assert(rel);
-
-
+
+
/* break down the relative URL (not cached, corruptable) */
status = url_get_components(rel,
(struct url_components *)&rel_components);
@@ -761,11 +761,13 @@
* Escape a string suitable for inclusion in an URL.
*
* \param unescaped the unescaped string
+ * \param sptoplus true iff spaces should be converted to +
* \param result pointer to pointer to buffer to hold escaped string
* \return URL_FUNC_OK on success
*/
-url_func_result url_escape(const char *unescaped, char **result)
+url_func_result url_escape(const char *unescaped, bool sptoplus,
+ char **result)
{
int len;
char *escaped, *d;
@@ -786,9 +788,13 @@
if (!isascii(*c) ||
strchr(";/?:@&=+$," "<>#%\"{}|\\^[]`", *c) ||
*c <= 0x20 || *c == 0x7f) {
- *d++ = '%';
- *d++ = "0123456789ABCDEF"[((*c >> 4) & 0xf)];
- *d++ = "0123456789ABCDEF"[(*c & 0xf)];
+ if (*c == 0x20 && sptoplus)
+ *d++ = '+';
+ else {
+ *d++ = '%';
+ *d++ = "0123456789ABCDEF"[((*c >> 4) & 0xf)];
+ *d++ = "0123456789ABCDEF"[(*c & 0xf)];
+ }
}
else {
/* unreserved characters: [a-zA-Z0-9-_.!~*'()] */
Modified: trunk/netsurf/utils/url.h
URL: http://svn.semichrome.net/trunk/netsurf/utils/url.h?rev=2960&r1=2959&r2=2...
==============================================================================
--- trunk/netsurf/utils/url.h (original)
+++ trunk/netsurf/utils/url.h Tue Sep 19 11:08:33 2006
@@ -35,7 +35,8 @@
url_func_result url_scheme(const char *url, char **result);
url_func_result url_nice(const char *url, char **result,
bool remove_extensions);
-url_func_result url_escape(const char *unescaped, char **result);
+url_func_result url_escape(const char *unescaped, bool sptoplus,
+ char **result);
url_func_result url_canonical_root(const char *url, char **result);
url_func_result url_parent(const char *url, char **result);
url_func_result url_plq(const char *url, char **result);
16 years, 8 months
r2959 jmb - /trunk/netsurf/render/imagemap.c
by netsurf@semichrome.net
Author: jmb
Date: Mon Sep 18 01:16:39 2006
New Revision: 2959
URL: http://svn.semichrome.net?rev=2959&view=rev
Log:
Fix 1559653.
Modified:
trunk/netsurf/render/imagemap.c
Modified: trunk/netsurf/render/imagemap.c
URL: http://svn.semichrome.net/trunk/netsurf/render/imagemap.c?rev=2959&r1=295...
==============================================================================
--- trunk/netsurf/render/imagemap.c (original)
+++ trunk/netsurf/render/imagemap.c Mon Sep 18 01:16:39 2006
@@ -235,8 +235,13 @@
if (node->type == XML_ELEMENT_NODE) {
if (strcmp(node->name, "map") == 0) {
- if ((name = (char*)xmlGetProp(node, (const xmlChar*)"name")) == NULL)
- return true;
+ if ((name = (char *)xmlGetProp(node,
+ (const xmlChar *)"id")) == NULL) {
+ if ((name = (char *)xmlGetProp(node,
+ (const xmlChar *)"name")) ==
+ NULL)
+ return true;
+ }
if (!imagemap_extract_map(node, c, &entry)) {
xmlFree(name);
return false;
16 years, 8 months
r2958 jmb - /trunk/netsurf/content/urldb.c
by netsurf@semichrome.net
Author: jmb
Date: Mon Sep 18 00:10:42 2006
New Revision: 2958
URL: http://svn.semichrome.net?rev=2958&view=rev
Log:
Ensure urldb_add_path always has a path.
Extract hostname from url authority returned by url_get_components.
Modified:
trunk/netsurf/content/urldb.c
Modified: trunk/netsurf/content/urldb.c
URL: http://svn.semichrome.net/trunk/netsurf/content/urldb.c?rev=2958&r1=2957&...
==============================================================================
--- trunk/netsurf/content/urldb.c (original)
+++ trunk/netsurf/content/urldb.c Mon Sep 18 00:10:42 2006
@@ -120,7 +120,7 @@
};
struct cache_internal_data {
- char filename[12]; /**< Cached filename, or first byte 0 for none */
+ char filename[12]; /**< Cached filename, or first byte 0 for none */
};
struct url_internal_data {
@@ -425,7 +425,7 @@
(port ? ports : ""),
s);
- p = urldb_add_path(scheme, port, h, s, NULL, NULL,
+ p = urldb_add_path(scheme, port, h, s, NULL, NULL,
url);
if (!p) {
LOG(("Failed inserting '%s'", url));
@@ -710,6 +710,7 @@
struct host_part *h;
struct path_data *p;
char *colon;
+ const char *host;
unsigned short port;
url_func_result ret;
struct url_components components;
@@ -721,8 +722,15 @@
if (ret != URL_FUNC_OK)
return false;
+ /* Extract host part from authority */
+ host = strchr(components.authority, '@');
+ if (!host)
+ host = components.authority;
+ else
+ host++;
+
/* get port and remove from authority */
- colon = strrchr(components.authority, ':');
+ colon = strrchr(host, ':');
if (!colon) {
port = 0;
} else {
@@ -734,21 +742,22 @@
if (strcasecmp(components.scheme, "file") == 0)
h = urldb_add_host("localhost");
else
- h = urldb_add_host(components.authority);
+ h = urldb_add_host(host);
if (!h) {
url_destroy_components(&components);
return false;
}
/* Get path entry */
- p = urldb_add_path(components.scheme, port, h, components.path,
+ p = urldb_add_path(components.scheme, port, h,
+ components.path ? components.path : "",
components.query, components.fragment, url);
if (!p) {
return false;
}
url_destroy_components(&components);
-
+
return true;
}
@@ -1578,8 +1587,8 @@
* \return Pointer to leaf node, or NULL on memory exhaustion
*/
struct path_data *urldb_add_path(const char *scheme, unsigned int port,
- const struct host_part *host, const char *path, const char *query,
- const char *fragment, const char *url)
+ const struct host_part *host, const char *path,
+ const char *query, const char *fragment, const char *url)
{
struct path_data *d, *e;
char *buf, *copy;
@@ -1605,10 +1614,10 @@
copy += strlen(path);
}
if (query) {
- *copy++ = '?';
- strcpy(copy, query);
- }
-
+ *copy++ = '?';
+ strcpy(copy, query);
+ }
+
/* skip leading '/' */
segment = buf;
if (*segment == '/')
@@ -3364,7 +3373,7 @@
p = urldb_find_url(url);
if (!p)
return false;
-
+
/* new filename needed */
if (p->cache.filename[0] == 0) {
filename = filename_request();
@@ -3372,7 +3381,7 @@
return false;
sprintf(p->cache.filename, filename);
}
-
+
/* todo: save content, set cache data etc */
return true;
}
@@ -3392,7 +3401,7 @@
p = urldb_find_url(url);
if (!p)
return NULL;
-
+
/* no file cache */
if (p->cache.filename[0] == 0)
return NULL;
16 years, 8 months
r2957 bursa - /trunk/netsurf/render/layout.c
by netsurf@semichrome.net
Author: bursa
Date: Sat Sep 16 22:48:28 2006
New Revision: 2957
URL: http://svn.semichrome.net?rev=2957&view=rev
Log:
Add some documentation to layout_block_context(). Move code out into layout_block_object().
Modified:
trunk/netsurf/render/layout.c
Modified: trunk/netsurf/render/layout.c
URL: http://svn.semichrome.net/trunk/netsurf/render/layout.c?rev=2957&r1=2956&...
==============================================================================
--- trunk/netsurf/render/layout.c (original)
+++ trunk/netsurf/render/layout.c Sat Sep 16 22:48:28 2006
@@ -46,6 +46,7 @@
static void layout_minmax_block(struct box *block);
+static bool layout_block_object(struct box *block);
static void layout_block_find_dimensions(int available_width, struct box *box);
static int layout_solve_width(int available_width, int width,
int margin[4], int padding[4], int border[4]);
@@ -143,7 +144,7 @@
/**
* Layout a block formatting context.
*
- * \param block BLOCK, INLINE_BLOCK, or TABLE_CELL to layout.
+ * \param block BLOCK, INLINE_BLOCK, or TABLE_CELL to layout
* \param content memory pool for any new boxes
* \return true on success, false on memory exhaustion
*
@@ -154,8 +155,7 @@
bool layout_block_context(struct box *block, struct content *content)
{
struct box *box;
- int cx;
- int cy;
+ int cx, cy; /**< current coordinates */
int max_pos_margin = 0;
int max_neg_margin = 0;
int y;
@@ -169,28 +169,40 @@
block->float_children = 0;
- if (block->object) {
- if (block->object->type == CONTENT_HTML) {
- box = block->object->data.html.layout;
- box->width = block->width;
- box->height = AUTO;
- if (!layout_block_context(box, block->object))
- return false;
- block->height = box->height;
- layout_calculate_descendant_bboxes(box);
- block->object->width = box->descendant_x1;
- block->object->height = box->descendant_y1;
- } else {
- }
- return true;
- }
+ /* special case if the block contains an object */
+ if (block->object)
+ return layout_block_object(block);
box = margin_box = block->children;
+ /* set current coordinates to top-left of the block */
cx = 0;
cy = block->padding[TOP];
if (box)
box->y = block->padding[TOP];
+ /* Step through the descendants of the block in depth-first order, but
+ * not into the children of boxes which aren't blocks. For example, if
+ * the tree passed to this function looks like this (box->type shown):
+ *
+ * block -> BOX_BLOCK
+ * BOX_BLOCK * (1)
+ * BOX_INLINE_CONTAINER * (2)
+ * BOX_INLINE
+ * BOX_TEXT
+ * ...
+ * BOX_BLOCK * (3)
+ * BOX_TABLE * (4)
+ * BOX_TABLE_ROW
+ * BOX_TABLE_CELL
+ * ...
+ * BOX_TABLE_CELL
+ * ...
+ * BOX_BLOCK * (5)
+ * BOX_INLINE_CONTAINER * (6)
+ * BOX_TEXT
+ * ...
+ * then the while loop will visit each box marked with *, setting box
+ * to each in the order shown. */
while (box) {
assert(box->type == BOX_BLOCK || box->type == BOX_TABLE ||
box->type == BOX_INLINE_CONTAINER);
@@ -248,19 +260,8 @@
/* Layout (except tables). */
if (box->object) {
- if (box->object->type == CONTENT_HTML) {
- box->object->data.html.layout->width =
- box->width;
- if (!layout_block_context(box->object->
- data.html.layout, box->object))
- return false;
- box->height = box->object->
- data.html.layout->height;
- /* + margins etc. */
- } else {
- /* this case handled already in
- * layout_block_find_dimensions() */
- }
+ if (!layout_block_object(box))
+ return false;
} else if (box->type == BOX_INLINE_CONTAINER) {
box->width = box->parent->width;
if (!layout_inline_container(box, box->width, block,
@@ -477,6 +478,37 @@
/**
+ * Layout a block which contains an object.
+ *
+ * \param block box of type BLOCK, INLINE_BLOCK, TABLE, or TABLE_CELL
+ * \return true on success, false on memory exhaustion
+ */
+
+bool layout_block_object(struct box *block)
+{
+ assert(block);
+ assert(block->type == BOX_BLOCK ||
+ block->type == BOX_INLINE_BLOCK ||
+ block->type == BOX_TABLE ||
+ block->type == BOX_TABLE_CELL);
+ assert(block->object);
+
+ LOG(("block %p, object %s, width %i", block, block->object->url,
+ block->width));
+
+ if (block->object->type == CONTENT_HTML) {
+ content_reformat(block->object, block->width, 1);
+ block->height = block->object->height;
+ } else {
+ /* this case handled already in
+ * layout_block_find_dimensions() */
+ }
+
+ return true;
+}
+
+
+/**
* Compute dimensions of box, margins, paddings, and borders for a block-level
* element.
*
@@ -523,11 +555,13 @@
if (style->overflow == CSS_OVERFLOW_SCROLL ||
style->overflow == CSS_OVERFLOW_AUTO) {
/* make space for scrollbars */
- if ((style->overflow == CSS_OVERFLOW_SCROLL) || box_hscrollbar_present(box)) {
+ if (style->overflow == CSS_OVERFLOW_SCROLL ||
+ box_hscrollbar_present(box)) {
box->height -= SCROLLBAR_WIDTH;
box->padding[BOTTOM] += SCROLLBAR_WIDTH;
}
- if ((style->overflow == CSS_OVERFLOW_SCROLL) || box_vscrollbar_present(box)) {
+ if (style->overflow == CSS_OVERFLOW_SCROLL ||
+ box_vscrollbar_present(box)) {
box->width -= SCROLLBAR_WIDTH;
box->padding[RIGHT] += SCROLLBAR_WIDTH;
}
16 years, 8 months
r2956 bursa - /trunk/netsurf/render/html.c
by netsurf@semichrome.net
Author: bursa
Date: Sat Sep 16 22:33:55 2006
New Revision: 2956
URL: http://svn.semichrome.net?rev=2956&view=rev
Log:
Call html_reformat() from html_convert() to eliminate duplicate code. Improve calculations of document width and height.
Modified:
trunk/netsurf/render/html.c
Modified: trunk/netsurf/render/html.c
URL: http://svn.semichrome.net/trunk/netsurf/render/html.c?rev=2956&r1=2955&r2...
==============================================================================
--- trunk/netsurf/render/html.c (original)
+++ trunk/netsurf/render/html.c Sat Sep 16 22:33:55 2006
@@ -353,10 +353,8 @@
content_set_status(c, messages_get("Formatting"));
content_broadcast(c, CONTENT_MSG_STATUS, msg_data);
LOG(("Layout document"));
- layout_document(c, width, height);
+ html_reformat(c, width, height);
/*box_dump(c->data.html.layout->children, 0);*/
- c->width = c->data.html.layout->descendant_x1;
- c->height = c->data.html.layout->descendant_y1;
c->size = talloc_total_size(c);
@@ -431,7 +429,7 @@
content_broadcast(c, CONTENT_MSG_REFRESH, msg_data);
break;
}
-
+
for ( ; url <= end - 4; url++) {
if (!strncasecmp(url, "url=", 4))
break;
@@ -445,7 +443,7 @@
url++;
}
}
-
+
if (url <= end - 4) {
res = url_join(url + 4, c->data.html.base_url,
&refresh);
@@ -1403,17 +1401,25 @@
void html_reformat(struct content *c, int width, int height)
{
- struct box *doc;
-
+ struct box *layout;
+
layout_document(c, width, height);
- doc = c->data.html.layout;
-
- c->width = doc->descendant_x1 +
- doc->margin[LEFT] + doc->margin[RIGHT];
-
- c->height = doc->descendant_y1 +
- doc->margin[TOP] + doc->margin[BOTTOM];
-
+ layout = c->data.html.layout;
+
+ /* width and height are at least margin box of document */
+ c->width = layout->x + layout->padding[LEFT] + layout->width +
+ layout->padding[RIGHT] + layout->border[RIGHT] +
+ layout->margin[RIGHT];
+ c->height = layout->y + layout->padding[TOP] + layout->height +
+ layout->padding[BOTTOM] + layout->border[BOTTOM] +
+ layout->margin[BOTTOM];
+
+ /* if boxes overflow right or bottom edge, expand to contain it */
+ if (c->width < layout->x + layout->descendant_x1)
+ c->width = layout->x + layout->descendant_x1;
+ if (c->height < layout->y + layout->descendant_y1)
+ c->height = layout->y + layout->descendant_y1;
+
if ((c->data.html.frameset) && (c->data.html.bw))
browser_window_recalculate_frameset(c->data.html.bw);
if ((c->data.html.iframe) && (c->data.html.bw))
@@ -1443,7 +1449,7 @@
/* Free base target */
if (c->data.html.base_target) {
talloc_free(c->data.html.base_target);
- c->data.html.base_target = NULL;
+ c->data.html.base_target = NULL;
}
/* Free frameset */
@@ -1471,7 +1477,7 @@
}
talloc_free(c->data.html.working_stylesheet);
-
+
/*if (c->data.html.style)
css_free_style(c->data.html.style);*/
@@ -1490,7 +1496,7 @@
void html_destroy_frameset(struct content_html_frames *frameset) {
int i;
-
+
if (frameset->name) {
talloc_free(frameset->name);
frameset->name = NULL;
@@ -1526,7 +1532,7 @@
talloc_free(iframe->name);
if (iframe->url)
talloc_free(iframe->url);
- talloc_free(iframe);
+ talloc_free(iframe);
}
}
@@ -1554,7 +1560,7 @@
c->data.html.object[i].box,
c->data.html.object[i].box->object_params);
}
-
+
if (c->data.html.frameset)
browser_window_create_frameset(bw, c->data.html.frameset);
if (c->data.html.iframe)
16 years, 8 months
r2955 bursa - /trunk/netsurftest/object-block.html
by netsurf@semichrome.net
Author: bursa
Date: Sat Sep 16 22:15:59 2006
New Revision: 2955
URL: http://svn.semichrome.net?rev=2955&view=rev
Log:
Test-case for objects with display: block or table-cell.
Added:
trunk/netsurftest/object-block.html
Added: trunk/netsurftest/object-block.html
URL: http://svn.semichrome.net/trunk/netsurftest/object-block.html?rev=2955&vi...
==============================================================================
--- trunk/netsurftest/object-block.html (added)
+++ trunk/netsurftest/object-block.html Sat Sep 16 22:15:59 2006
@@ -1,0 +1,34 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
+ "http://www.w3.org/TR/html4/strict.dtd">
+<html>
+<head>
+<title>Block object test</title>
+</head>
+
+<body>
+
+<h1>Block object test</h1>
+
+<h2>Test 1</h2>
+<div>
+<object type="text/html" data="color.html" style="display: block">
+Hello, world!
+</object>
+</div>
+
+<h2>Test 2</h2>
+<div>
+<object type="text/html" data="color.html" style="display: table-cell">
+Hello, world!
+</object>
+</div>
+
+<h2>Test 3</h2>
+<div>
+<object data="drawing" style="display: block">
+Hello, world!
+</object>
+</div>
+
+</body>
+</html>
16 years, 8 months
r2953 jmb - /trunk/netsurf/render/box_construct.c
by netsurf@semichrome.net
Author: jmb
Date: Mon Sep 11 12:55:17 2006
New Revision: 2953
URL: http://svn.semichrome.net?rev=2953&view=rev
Log:
Squash warnings.
Modified:
trunk/netsurf/render/box_construct.c
Modified: trunk/netsurf/render/box_construct.c
URL: http://svn.semichrome.net/trunk/netsurf/render/box_construct.c?rev=2953&r...
==============================================================================
--- trunk/netsurf/render/box_construct.c (original)
+++ trunk/netsurf/render/box_construct.c Mon Sep 11 12:55:17 2006
@@ -1400,8 +1400,11 @@
if (!box_get_attribute(c, "valuetype", param,
¶m->valuetype))
return false;
- if (!param->valuetype)
- param->valuetype = "data";
+ if (!param->valuetype) {
+ param->valuetype = talloc_strdup(param, "data");
+ if (!param->valuetype)
+ return false;
+ }
param->next = params->params;
params->params = param;
@@ -1574,11 +1577,11 @@
LOG(("Error: multiple framesets in document."));
return false;
}
-
+
content->data.html.frameset = talloc_zero(content, struct content_html_frames);
if (!content->data.html.frameset)
return false;
-
+
ok = box_create_frameset(content->data.html.frameset, n, content);
if (ok)
box->style->display = CSS_DISPLAY_NONE;
@@ -1647,7 +1650,7 @@
default_border_colour = named_colour(s);
xmlFree(s);
}
-
+
/* update frameset and create default children */
f->cols = cols;
f->rows = rows;
@@ -1824,7 +1827,7 @@
if ((s = (char *) xmlGetProp(n,
(const xmlChar *) "name"))) {
iframe->name = talloc_strdup(content, s);
- xmlFree(s);
+ xmlFree(s);
}
if ((s = (char *) xmlGetProp(n,
(const xmlChar *) "frameborder"))) {
@@ -1858,7 +1861,7 @@
iframe->margin_width = atoi(s);
xmlFree(s);
}
-
+
/* release temporary memory */
free(url);
@@ -2392,9 +2395,10 @@
* Consecutive BR may not be present. These constraints are satisfied
* by using a 0-length TEXT for blank lines. */
- xmlChar *current,*string,*null_string="";
+ xmlChar *current, *string;
xmlNode *n2;
xmlBufferPtr buf;
+ xmlParserCtxtPtr ctxt;
struct box *inline_container, *inline_box, *br_box;
char *s;
size_t len;
@@ -2421,29 +2425,42 @@
n2 = n->children;
buf = xmlBufferCreate();
while(n2) {
- int ret = xmlNodeDump(buf,n2->doc,n2,0,0);
+ int ret = xmlNodeDump(buf, n2->doc, n2, 0, 0);
if (ret == -1) {
xmlBufferFree(buf);
return false;
}
n2 = n2->next;
}
- xmlParserCtxtPtr ctxt = xmlCreateDocParserCtxt(buf->content);
- string=0;
- if(ctxt)
- {
- string = current = xmlStringDecodeEntities(ctxt,buf->content,XML_SUBSTITUTE_REF|XML_SUBSTITUTE_PEREF,0,0,0);
+
+ ctxt = xmlCreateDocParserCtxt(buf->content);
+ string = current = NULL;
+ if (ctxt) {
+ string = current = xmlStringDecodeEntities(ctxt,
+ buf->content,
+ XML_SUBSTITUTE_REF | XML_SUBSTITUTE_PEREF,
+ 0, 0, 0);
xmlFreeParserCtxt(ctxt);
}
- if(!string)
- string = current = null_string;
+
+ if (!string) {
+ /* If we get here, either the parser context failed to be
+ * created or we were unable to decode the entities in the
+ * buffer. Therefore, try to create a blank string in order
+ * to recover. */
+ string = current = xmlStrdup((const xmlChar *) "");
+ if (!string) {
+ xmlBufferFree(buf);
+ return false;
+ }
+ }
+
while (1) {
/* BOX_TEXT */
len = strcspn(current, "\r\n");
s = talloc_strndup(content, current, len);
if (!s) {
- if(string != null_string)
- xmlFree(string);
+ xmlFree(string);
xmlBufferFree(buf);
return false;
}
@@ -2451,8 +2468,7 @@
inline_box = box_create(box->style, 0, 0, box->title, 0,
content);
if (!inline_box) {
- if(string != null_string)
- xmlFree(string);
+ xmlFree(string);
xmlBufferFree(buf);
return false;
}
@@ -2469,8 +2485,7 @@
/* BOX_BR */
br_box = box_create(box->style, 0, 0, box->title, 0, content);
if (!br_box) {
- if(string != null_string)
- xmlFree(string);
+ xmlFree(string);
xmlBufferFree(buf);
return false;
}
@@ -2482,8 +2497,8 @@
else
current++;
}
- if(string != null_string)
- xmlFree(string);
+
+ xmlFree(string);
xmlBufferFree(buf);
if (content->data.html.forms)
@@ -2544,10 +2559,10 @@
param->value = talloc_strdup(content,
(char *) a->children->content);
param->type = 0;
- param->valuetype = "data";
+ param->valuetype = talloc_strdup(content, "data");
param->next = 0;
- if (!param->name || !param->value)
+ if (!param->name || !param->value || !param->valuetype)
return false;
param->next = params->params;
16 years, 8 months
r2952 phlamethrower - /trunk/netsurf/render/box_construct.c
by netsurf@semichrome.net
Author: phlamethrower
Date: Mon Sep 11 09:02:13 2006
New Revision: 2952
URL: http://svn.semichrome.net?rev=2952&view=rev
Log:
Fixed translation of html entities when a textarea has an initial value
Modified:
trunk/netsurf/render/box_construct.c
Modified: trunk/netsurf/render/box_construct.c
URL: http://svn.semichrome.net/trunk/netsurf/render/box_construct.c?rev=2952&r...
==============================================================================
--- trunk/netsurf/render/box_construct.c (original)
+++ trunk/netsurf/render/box_construct.c Mon Sep 11 09:02:13 2006
@@ -20,6 +20,7 @@
#include <stdlib.h>
#include <string.h>
#include "libxml/HTMLparser.h"
+#include "libxml/parserInternals.h"
#include "netsurf/utils/config.h"
#include "netsurf/content/content.h"
#include "netsurf/css/css.h"
@@ -2391,7 +2392,7 @@
* Consecutive BR may not be present. These constraints are satisfied
* by using a 0-length TEXT for blank lines. */
- xmlChar *current;
+ xmlChar *current,*string,*null_string="";
xmlNode *n2;
xmlBufferPtr buf;
struct box *inline_container, *inline_box, *br_box;
@@ -2427,12 +2428,22 @@
}
n2 = n2->next;
}
- current = buf->content;
+ xmlParserCtxtPtr ctxt = xmlCreateDocParserCtxt(buf->content);
+ string=0;
+ if(ctxt)
+ {
+ string = current = xmlStringDecodeEntities(ctxt,buf->content,XML_SUBSTITUTE_REF|XML_SUBSTITUTE_PEREF,0,0,0);
+ xmlFreeParserCtxt(ctxt);
+ }
+ if(!string)
+ string = current = null_string;
while (1) {
/* BOX_TEXT */
len = strcspn(current, "\r\n");
s = talloc_strndup(content, current, len);
if (!s) {
+ if(string != null_string)
+ xmlFree(string);
xmlBufferFree(buf);
return false;
}
@@ -2440,6 +2451,8 @@
inline_box = box_create(box->style, 0, 0, box->title, 0,
content);
if (!inline_box) {
+ if(string != null_string)
+ xmlFree(string);
xmlBufferFree(buf);
return false;
}
@@ -2456,6 +2469,8 @@
/* BOX_BR */
br_box = box_create(box->style, 0, 0, box->title, 0, content);
if (!br_box) {
+ if(string != null_string)
+ xmlFree(string);
xmlBufferFree(buf);
return false;
}
@@ -2467,6 +2482,8 @@
else
current++;
}
+ if(string != null_string)
+ xmlFree(string);
xmlBufferFree(buf);
if (content->data.html.forms)
16 years, 8 months