summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGustavo Noronha Silva <gns@gnome.org>2009-12-27 23:43:06 -0200
committerGustavo Noronha Silva <gns@gnome.org>2009-12-27 23:43:06 -0200
commit379145060b8fc90fa7c81c0bff20d025e61adc38 (patch)
tree7d5bab1418bd7cb81d668077734e872093df6e5d
parentdd93ab5575b53d05a574a4be8a0f86501ef933e9 (diff)
downloadyelp-379145060b8fc90fa7c81c0bff20d025e61adc38.tar.gz
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>.
-rw-r--r--src/yelp-html.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/yelp-html.c b/src/yelp-html.c
index bc07c37b..fae92748 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;