[yelp/webkit] Use GString instead of a plain string to hold content
- From: Gustavo Noronha Silva <gns src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [yelp/webkit] Use GString instead of a plain string to hold content
- Date: Mon, 28 Dec 2009 01:46:04 +0000 (UTC)
commit 379145060b8fc90fa7c81c0bff20d025e61adc38
Author: Gustavo Noronha Silva <gns gnome org>
Date: Sun Dec 27 23:43:06 2009 -0200
Use GString instead of a plain string to hold content
Yelp was holding the string that it gives WebKit for loading in a
plain string, and ignoring the explicit length argument. In some cases
the string was not correctly terminated by \0, and the document ended
up with garbage. This was causing most of the XML parsing error
messages that were being observed.
This patch was made with help from Luciana Fujii <luciana fujii eti br>.
src/yelp-html.c | 15 +++++++--------
1 files changed, 7 insertions(+), 8 deletions(-)
---
diff --git a/src/yelp-html.c b/src/yelp-html.c
index bc07c37..fae9274 100644
--- a/src/yelp-html.c
+++ b/src/yelp-html.c
@@ -38,7 +38,7 @@
#define YELP_HTML_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), YELP_TYPE_HTML, YelpHtmlPriv))
struct _YelpHtmlPriv {
- gchar *content;
+ GString *content;
gchar *mime;
gchar *find_string;
gboolean initialised;
@@ -347,7 +347,8 @@ yelp_html_open_stream (YelpHtml *html, const gchar *mime)
debug_print (DB_FUNCTION, "entering\n");
html->priv->frames_enabled = FALSE;
- g_free (html->priv->content);
+ if (html->priv->content)
+ g_string_free (html->priv->content, TRUE);
html->priv->content = NULL;
g_free (html->priv->mime);
html->priv->mime = g_strdup(mime);
@@ -365,11 +366,9 @@ yelp_html_write (YelpHtml *html, const gchar *data, gint len)
debug_print (DB_ARG, " len = %i\n", len);
if (html->priv->content) {
- tmp = g_strjoin (NULL, html->priv->content, data, NULL);
- g_free (html->priv->content);
- html->priv->content = tmp;
+ g_string_append_len (html->priv->content, data, len);
} else {
- html->priv->content = g_strdup (data);
+ html->priv->content = g_string_new_len (data, len);
}
}
@@ -413,11 +412,11 @@ yelp_html_close (YelpHtml *html)
}
webkit_web_view_load_string (WEBKIT_WEB_VIEW (html),
- html->priv->content,
+ html->priv->content->str,
html->priv->mime,
NULL,
html->priv->base_uri);
- g_free (html->priv->content);
+ g_string_free (html->priv->content, TRUE);
html->priv->content = NULL;
g_free (html->priv->mime);
html->priv->mime = NULL;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]