[libgdata] [core] Added a method to escape text and append it to a GString
- From: Philip Withnall <pwithnall src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [libgdata] [core] Added a method to escape text and append it to a GString
- Date: Mon, 3 Aug 2009 17:36:45 +0000 (UTC)
commit d61d33f99968e7493afccadd9816a7a3d2f95128
Author: Philip Withnall <philip tecnocode co uk>
Date: Mon Aug 3 18:35:59 2009 +0100
[core] Added a method to escape text and append it to a GString
This reduces the number of small allocations required when building up
an XML output tree by a large number. XML output checks in the test
suites can act as a test case.
gdata/atom/gdata-author.c | 19 ++----
gdata/atom/gdata-category.c | 7 +--
gdata/atom/gdata-link.c | 14 +---
gdata/gd/gdata-gd-email-address.c | 7 +--
gdata/gd/gdata-gd-im-address.c | 7 +--
gdata/gd/gdata-gd-organization.c | 21 ++-----
gdata/gd/gdata-gd-phone-number.c | 14 +---
gdata/gd/gdata-gd-postal-address.c | 7 +--
gdata/gd/gdata-gd-where.c | 14 +---
gdata/gd/gdata-gd-who.c | 7 +--
gdata/gdata-entry.c | 26 ++------
gdata/gdata-parsable.c | 2 +-
gdata/gdata-parser.c | 68 +++++++++++++++++++++
gdata/gdata-parser.h | 1 +
gdata/gdata-private.h | 1 +
gdata/media/gdata-media-category.c | 14 +---
gdata/media/gdata-media-group.c | 21 ++-----
gdata/services/calendar/gdata-calendar-calendar.c | 7 +--
gdata/services/calendar/gdata-calendar-event.c | 2 -
gdata/services/contacts/gdata-contacts-contact.c | 2 -
gdata/services/picasaweb/gdata-picasaweb-album.c | 9 +--
gdata/services/picasaweb/gdata-picasaweb-file.c | 16 +----
gdata/services/youtube/gdata-youtube-video.c | 7 +--
23 files changed, 128 insertions(+), 165 deletions(-)
---
diff --git a/gdata/atom/gdata-author.c b/gdata/atom/gdata-author.c
index 4ded148..6e4b5f4 100644
--- a/gdata/atom/gdata-author.c
+++ b/gdata/atom/gdata-author.c
@@ -245,23 +245,14 @@ static void
get_xml (GDataParsable *parsable, GString *xml_string)
{
GDataAuthorPrivate *priv = GDATA_AUTHOR (parsable)->priv;
- gchar *name;
- name = g_markup_escape_text (priv->name, -1);
- g_string_append_printf (xml_string, "<name>%s</name>", name);
- g_free (name);
+ gdata_parser_string_append_escaped (xml_string, "<name>", priv->name, "</name>");
- if (priv->uri != NULL) {
- gchar *uri = g_markup_escape_text (priv->uri, -1);
- g_string_append_printf (xml_string, "<uri>%s</uri>", uri);
- g_free (uri);
- }
+ if (priv->uri != NULL)
+ gdata_parser_string_append_escaped (xml_string, "<uri>", priv->uri, "</uri>");
- if (priv->email_address != NULL) {
- gchar *email = g_markup_escape_text (priv->email_address, -1);
- g_string_append_printf (xml_string, "<email>%s</email>", email);
- g_free (email);
- }
+ if (priv->email_address != NULL)
+ gdata_parser_string_append_escaped (xml_string, "<email>", priv->email_address, "</email>");
}
/**
diff --git a/gdata/atom/gdata-category.c b/gdata/atom/gdata-category.c
index d8be2cc..60f8f4e 100644
--- a/gdata/atom/gdata-category.c
+++ b/gdata/atom/gdata-category.c
@@ -216,11 +216,8 @@ pre_get_xml (GDataParsable *parsable, GString *xml_string)
if (priv->scheme != NULL)
g_string_append_printf (xml_string, " scheme='%s'", priv->scheme);
- if (priv->label != NULL) {
- gchar *label = g_markup_escape_text (priv->label, -1);
- g_string_append_printf (xml_string, " label='%s'", label);
- g_free (label);
- }
+ if (priv->label != NULL)
+ gdata_parser_string_append_escaped (xml_string, " label='", priv->label, "'");
}
/**
diff --git a/gdata/atom/gdata-link.c b/gdata/atom/gdata-link.c
index 70bdc00..4375738 100644
--- a/gdata/atom/gdata-link.c
+++ b/gdata/atom/gdata-link.c
@@ -322,18 +322,10 @@ pre_get_xml (GDataParsable *parsable, GString *xml_string)
{
GDataLinkPrivate *priv = GDATA_LINK (parsable)->priv;
- {
- gchar *href = g_markup_escape_text (priv->uri, -1);
- g_string_append_printf (xml_string, " href='%s'", href);
- g_free (href);
- }
-
- if (priv->title != NULL) {
- gchar *link_title = g_markup_escape_text (priv->title, -1);
- g_string_append_printf (xml_string, " title='%s'", link_title);
- g_free (link_title);
- }
+ gdata_parser_string_append_escaped (xml_string, " href='", priv->uri, "'");
+ if (priv->title != NULL)
+ gdata_parser_string_append_escaped (xml_string, " title='", priv->title, "'");
if (priv->relation_type != NULL)
g_string_append_printf (xml_string, " rel='%s'", priv->relation_type);
if (priv->content_type != NULL)
diff --git a/gdata/gd/gdata-gd-email-address.c b/gdata/gd/gdata-gd-email-address.c
index 0a60f2a..b6bc7c4 100644
--- a/gdata/gd/gdata-gd-email-address.c
+++ b/gdata/gd/gdata-gd-email-address.c
@@ -265,11 +265,8 @@ pre_get_xml (GDataParsable *parsable, GString *xml_string)
g_string_append_printf (xml_string, " address='%s'", priv->address);
if (priv->relation_type != NULL)
g_string_append_printf (xml_string, " rel='%s'", priv->relation_type);
- if (priv->label != NULL) {
- gchar *label = g_markup_escape_text (priv->label, -1);
- g_string_append_printf (xml_string, " label='%s'", label);
- g_free (label);
- }
+ if (priv->label != NULL)
+ gdata_parser_string_append_escaped (xml_string, " label='", priv->label, "'");
if (priv->is_primary == TRUE)
g_string_append (xml_string, " primary='true'");
diff --git a/gdata/gd/gdata-gd-im-address.c b/gdata/gd/gdata-gd-im-address.c
index d8025f1..074193b 100644
--- a/gdata/gd/gdata-gd-im-address.c
+++ b/gdata/gd/gdata-gd-im-address.c
@@ -298,11 +298,8 @@ pre_get_xml (GDataParsable *parsable, GString *xml_string)
if (priv->relation_type != NULL)
g_string_append_printf (xml_string, " rel='%s'", priv->relation_type);
- if (priv->label != NULL) {
- gchar *label = g_markup_escape_text (priv->label, -1);
- g_string_append_printf (xml_string, " label='%s'", label);
- g_free (label);
- }
+ if (priv->label != NULL)
+ gdata_parser_string_append_escaped (xml_string, " label='", priv->label, "'");
if (priv->is_primary == TRUE)
g_string_append (xml_string, " primary='true'");
diff --git a/gdata/gd/gdata-gd-organization.c b/gdata/gd/gdata-gd-organization.c
index 9f4271a..9942623 100644
--- a/gdata/gd/gdata-gd-organization.c
+++ b/gdata/gd/gdata-gd-organization.c
@@ -320,11 +320,8 @@ pre_get_xml (GDataParsable *parsable, GString *xml_string)
if (priv->relation_type != NULL)
g_string_append_printf (xml_string, " rel='%s'", priv->relation_type);
- if (priv->label != NULL) {
- gchar *label = g_markup_escape_text (priv->label, -1);
- g_string_append_printf (xml_string, " label='%s'", label);
- g_free (label);
- }
+ if (priv->label != NULL)
+ gdata_parser_string_append_escaped (xml_string, " label='", priv->label, "'");
if (priv->is_primary == TRUE)
g_string_append (xml_string, " primary='true'");
@@ -337,17 +334,11 @@ get_xml (GDataParsable *parsable, GString *xml_string)
{
GDataGDOrganizationPrivate *priv = GDATA_GD_ORGANIZATION (parsable)->priv;
- if (priv->name != NULL) {
- gchar *name = g_markup_escape_text (priv->name, -1);
- g_string_append_printf (xml_string, "<gd:orgName>%s</gd:orgName>", name);
- g_free (name);
- }
+ if (priv->name != NULL)
+ gdata_parser_string_append_escaped (xml_string, "<gd:orgName>", priv->name, "</gd:orgName>");
- if (priv->title != NULL) {
- gchar *title = g_markup_escape_text (priv->title, -1);
- g_string_append_printf (xml_string, "<gd:orgTitle>%s</gd:orgTitle>", title);
- g_free (title);
- }
+ if (priv->title != NULL)
+ gdata_parser_string_append_escaped (xml_string, "<gd:orgTitle>", priv->title, "</gd:orgTitle>");
}
static void
diff --git a/gdata/gd/gdata-gd-phone-number.c b/gdata/gd/gdata-gd-phone-number.c
index 3691a94..16761d7 100644
--- a/gdata/gd/gdata-gd-phone-number.c
+++ b/gdata/gd/gdata-gd-phone-number.c
@@ -317,11 +317,8 @@ pre_get_xml (GDataParsable *parsable, GString *xml_string)
g_string_append_printf (xml_string, " uri='%s'", priv->uri);
if (priv->relation_type != NULL)
g_string_append_printf (xml_string, " rel='%s'", priv->relation_type);
- if (priv->label != NULL) {
- gchar *label = g_markup_escape_text (priv->label, -1);
- g_string_append_printf (xml_string, " label='%s'", label);
- g_free (label);
- }
+ if (priv->label != NULL)
+ gdata_parser_string_append_escaped (xml_string, " label='", priv->label, "'");
if (priv->is_primary == TRUE)
g_string_append (xml_string, " primary='true'");
@@ -332,12 +329,7 @@ pre_get_xml (GDataParsable *parsable, GString *xml_string)
static void
get_xml (GDataParsable *parsable, GString *xml_string)
{
- gchar *number;
- GDataGDPhoneNumberPrivate *priv = GDATA_GD_PHONE_NUMBER (parsable)->priv;
-
- number = g_markup_escape_text (priv->number, -1);
- g_string_append (xml_string, number);
- g_free (number);
+ gdata_parser_string_append_escaped (xml_string, NULL, GDATA_GD_PHONE_NUMBER (parsable)->priv->number, NULL);
}
static void
diff --git a/gdata/gd/gdata-gd-postal-address.c b/gdata/gd/gdata-gd-postal-address.c
index ff7af42..b8308ab 100644
--- a/gdata/gd/gdata-gd-postal-address.c
+++ b/gdata/gd/gdata-gd-postal-address.c
@@ -286,11 +286,8 @@ pre_get_xml (GDataParsable *parsable, GString *xml_string)
if (priv->relation_type != NULL)
g_string_append_printf (xml_string, " rel='%s'", priv->relation_type);
- if (priv->label != NULL) {
- gchar *label = g_markup_escape_text (priv->label, -1);
- g_string_append_printf (xml_string, " label='%s'", label);
- g_free (label);
- }
+ if (priv->label != NULL)
+ gdata_parser_string_append_escaped (xml_string, " label='", priv->label, "'");
if (priv->is_primary == TRUE)
g_string_append (xml_string, " primary='true'");
diff --git a/gdata/gd/gdata-gd-where.c b/gdata/gd/gdata-gd-where.c
index 2f8ca6d..d3db504 100644
--- a/gdata/gd/gdata-gd-where.c
+++ b/gdata/gd/gdata-gd-where.c
@@ -231,20 +231,14 @@ pre_get_xml (GDataParsable *parsable, GString *xml_string)
{
GDataGDWherePrivate *priv = GDATA_GD_WHERE (parsable)->priv;
- if (priv->label != NULL) {
- gchar *label = g_markup_escape_text (priv->label, -1);
- g_string_append_printf (xml_string, " label='%s'", label);
- g_free (label);
- }
+ if (priv->label != NULL)
+ gdata_parser_string_append_escaped (xml_string, " label='", priv->label, "'");
if (priv->relation_type != NULL)
g_string_append_printf (xml_string, " rel='%s'", priv->relation_type);
- if (priv->value_string != NULL) {
- gchar *value_string = g_markup_escape_text (priv->value_string, -1);
- g_string_append_printf (xml_string, " valueString='%s'", value_string);
- g_free (value_string);
- }
+ if (priv->value_string != NULL)
+ gdata_parser_string_append_escaped (xml_string, " valueString='", priv->value_string, "'");
}
static void
diff --git a/gdata/gd/gdata-gd-who.c b/gdata/gd/gdata-gd-who.c
index 2f3417e..5d0a5de 100644
--- a/gdata/gd/gdata-gd-who.c
+++ b/gdata/gd/gdata-gd-who.c
@@ -240,11 +240,8 @@ pre_get_xml (GDataParsable *parsable, GString *xml_string)
g_string_append_printf (xml_string, " email='%s'", priv->email_address);
if (priv->relation_type != NULL)
g_string_append_printf (xml_string, " rel='%s'", priv->relation_type);
- if (priv->value_string != NULL) {
- gchar *value_string = g_markup_escape_text (priv->value_string, -1);
- g_string_append_printf (xml_string, " valueString='%s'", value_string);
- g_free (value_string);
- }
+ if (priv->value_string != NULL)
+ gdata_parser_string_append_escaped (xml_string, " valueString='", priv->value_string, "'");
}
static void
diff --git a/gdata/gdata-entry.c b/gdata/gdata-entry.c
index d996af3..7e2b11d 100644
--- a/gdata/gdata-entry.c
+++ b/gdata/gdata-entry.c
@@ -439,12 +439,9 @@ static void
get_xml (GDataParsable *parsable, GString *xml_string)
{
GDataEntryPrivate *priv = GDATA_ENTRY (parsable)->priv;
- gchar *title;
GList *categories, *links, *authors;
- title = g_markup_escape_text (priv->title, -1);
- g_string_append_printf (xml_string, "<title type='text'>%s</title>", title);
- g_free (title);
+ gdata_parser_string_append_escaped (xml_string, "<title type='text'>", priv->title, "</title>");
if (priv->id != NULL)
g_string_append_printf (xml_string, "<id>%s</id>", priv->id);
@@ -461,23 +458,14 @@ get_xml (GDataParsable *parsable, GString *xml_string)
g_free (published);
}
- if (priv->summary != NULL) {
- gchar *summary = g_markup_escape_text (priv->summary, -1);
- g_string_append_printf (xml_string, "<summary type='text'>%s</summary>", summary);
- g_free (summary);
- }
+ if (priv->summary != NULL)
+ gdata_parser_string_append_escaped (xml_string, "<summary type='text'>", priv->summary, "</summary>");
- if (priv->rights != NULL) {
- gchar *rights = g_markup_escape_text (priv->rights, -1);
- g_string_append_printf (xml_string, "<rights>%s</rights>", rights);
- g_free (rights);
- }
+ if (priv->rights != NULL)
+ gdata_parser_string_append_escaped (xml_string, "<rights>", priv->rights, "</rights>");
- if (priv->content != NULL) {
- gchar *content = g_markup_escape_text (priv->content, -1);
- g_string_append_printf (xml_string, "<content type='text'>%s</content>", content);
- g_free (content);
- }
+ if (priv->content != NULL)
+ gdata_parser_string_append_escaped (xml_string, "<content type='text'>", priv->content, "</content>");
for (categories = priv->categories; categories != NULL; categories = categories->next)
_gdata_parsable_get_xml (GDATA_PARSABLE (categories->data), xml_string, FALSE);
diff --git a/gdata/gdata-parsable.c b/gdata/gdata-parsable.c
index e45e1b1..ae232a8 100644
--- a/gdata/gdata-parsable.c
+++ b/gdata/gdata-parsable.c
@@ -212,7 +212,7 @@ _gdata_parsable_new_from_xml_node (GType parsable_type, xmlDoc *doc, xmlNode *no
klass->pre_parse_xml (parsable, doc, node, user_data, error) == FALSE) {
g_object_unref (parsable);
return NULL;
- }
+ }
/* Parse each child element */
node = node->children;
diff --git a/gdata/gdata-parser.c b/gdata/gdata-parser.c
index dd241e5..8d136e1 100644
--- a/gdata/gdata-parser.c
+++ b/gdata/gdata-parser.c
@@ -203,3 +203,71 @@ gdata_parser_date_from_time_val (GTimeVal *_time)
/* Note: This doesn't need translating, as it's outputting an ISO 8601 date string */
return g_strdup_printf ("%4d-%02d-%02d", tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday);
}
+
+void
+gdata_parser_string_append_escaped (GString *xml_string, const gchar *pre, const gchar *element_content, const gchar *post)
+{
+ /* Allocate 10 extra bytes when reallocating the GString, to try and avoid having to reallocate again, by assuming
+ * there will be an increase in the length of element_content when escaped of less than 10 characters. */
+/* #define SIZE_FUZZINESS 10*/
+
+/* guint new_size;*/
+ const gchar *p;
+
+ /* Expand xml_string as necessary */
+ /* TODO: There is no way to expand the allocation of a GString if you know in advance how much room
+ * lots of append operations are going to require. */
+/* new_size = xml_string->len + strlen (pre) + strlen (element_content) + strlen (post) + SIZE_FUZZINESS;
+ if (new_size > xml_string->allocated_len)
+ g_string_set_size (xml_string, new_size);*/
+
+ /* Append the pre content */
+ if (pre != NULL)
+ g_string_append (xml_string, pre);
+
+ /* Loop through the string to be escaped. Code adapted from GLib's g_markup_escape_text() function.
+ * Copyright 2000, 2003 Red Hat, Inc.
+ * Copyright 2007, 2008 Ryan Lortie <desrt desrt ca>
+ */
+ p = element_content;
+ while (*p != '\0') {
+ const gchar *next = g_utf8_next_char (p);
+
+ switch (*p) {
+ case '&':
+ g_string_append (xml_string, "&");
+ break;
+ case '<':
+ g_string_append (xml_string, "<");
+ break;
+ case '>':
+ g_string_append (xml_string, ">");
+ break;
+ case '\'':
+ g_string_append (xml_string, "'");
+ break;
+ case '"':
+ g_string_append (xml_string, """);
+ break;
+ default: {
+ gunichar c = g_utf8_get_char (p);
+
+ if ((0x1 <= c && c <= 0x8) ||
+ (0xb <= c && c <= 0xc) ||
+ (0xe <= c && c <= 0x1f) ||
+ (0x7f <= c && c <= 0x84) ||
+ (0x86 <= c && c <= 0x9f)) {
+ g_string_append_printf (xml_string, "&#x%x;", c);
+ } else {
+ g_string_append_len (xml_string, p, next - p);
+ break;
+ }
+ }
+ }
+ p = next;
+ }
+
+ /* Append the post content */
+ if (post != NULL)
+ g_string_append (xml_string, post);
+}
diff --git a/gdata/gdata-parser.h b/gdata/gdata-parser.h
index b794c5c..e7c33fc 100644
--- a/gdata/gdata-parser.h
+++ b/gdata/gdata-parser.h
@@ -33,6 +33,7 @@ gboolean gdata_parser_error_required_element_missing (const gchar *element_name,
gboolean gdata_parser_error_duplicate_element (xmlNode *element, GError **error);
gboolean gdata_parser_time_val_from_date (const gchar *date, GTimeVal *_time);
gchar *gdata_parser_date_from_time_val (GTimeVal *_time) G_GNUC_WARN_UNUSED_RESULT;
+void gdata_parser_string_append_escaped (GString *xml_string, const gchar *pre, const gchar *element_content, const gchar *post);
G_END_DECLS
diff --git a/gdata/gdata-private.h b/gdata/gdata-private.h
index 162f35d..53729b4 100644
--- a/gdata/gdata-private.h
+++ b/gdata/gdata-private.h
@@ -47,6 +47,7 @@ GDataParsable *_gdata_parsable_new_from_xml (GType parsable_type, const gchar *x
GDataParsable *_gdata_parsable_new_from_xml_node (GType parsable_type, xmlDoc *doc, xmlNode *node, gpointer user_data,
GError **error) G_GNUC_WARN_UNUSED_RESULT;
void _gdata_parsable_get_xml (GDataParsable *self, GString *xml_string, gboolean declare_namespaces);
+void _gdata_parsable_string_append_escaped (GString *xml_string, const gchar *pre, const gchar *element_content, const gchar *post);
#include "gdata-feed.h"
GDataFeed *_gdata_feed_new_from_xml (GType feed_type, const gchar *xml, gint length, GType entry_type,
diff --git a/gdata/media/gdata-media-category.c b/gdata/media/gdata-media-category.c
index 582c6d8..6ef1480 100644
--- a/gdata/media/gdata-media-category.c
+++ b/gdata/media/gdata-media-category.c
@@ -245,22 +245,14 @@ pre_get_xml (GDataParsable *parsable, GString *xml_string)
if (priv->scheme != NULL)
g_string_append_printf (xml_string, " scheme='%s'", priv->scheme);
- if (priv->label != NULL) {
- gchar *label = g_markup_escape_text (priv->label, -1);
- g_string_append_printf (xml_string, " label='%s'", label);
- g_free (label);
- }
+ if (priv->label != NULL)
+ gdata_parser_string_append_escaped (xml_string, " label='", priv->label, "'");
}
static void
get_xml (GDataParsable *parsable, GString *xml_string)
{
- gchar *category;
- GDataMediaCategoryPrivate *priv = GDATA_MEDIA_CATEGORY (parsable)->priv;
-
- category = g_markup_escape_text (priv->category, -1);
- g_string_append (xml_string, category);
- g_free (category);
+ gdata_parser_string_append_escaped (xml_string, NULL, GDATA_MEDIA_CATEGORY (parsable)->priv->category, NULL);
}
static void
diff --git a/gdata/media/gdata-media-group.c b/gdata/media/gdata-media-group.c
index f4004d3..a15b851 100644
--- a/gdata/media/gdata-media-group.c
+++ b/gdata/media/gdata-media-group.c
@@ -266,23 +266,14 @@ get_xml (GDataParsable *parsable, GString *xml_string)
if (priv->category != NULL)
_gdata_parsable_get_xml (GDATA_PARSABLE (priv->category), xml_string, FALSE);
- if (priv->title != NULL) {
- gchar *title = g_markup_escape_text (priv->title, -1);
- g_string_append_printf (xml_string, "<media:title type='plain'>%s</media:title>", title);
- g_free (title);
- }
+ if (priv->title != NULL)
+ gdata_parser_string_append_escaped (xml_string, "<media:title type='plain'>", priv->title, "</media:title>");
- if (priv->description != NULL) {
- gchar *description = g_markup_escape_text (priv->description, -1);
- g_string_append_printf (xml_string, "<media:description type='plain'>%s</media:description>", description);
- g_free (description);
- }
+ if (priv->description != NULL)
+ gdata_parser_string_append_escaped (xml_string, "<media:description type='plain'>", priv->description, "</media:description>");
- if (priv->keywords != NULL) {
- gchar *keywords = g_markup_escape_text (priv->keywords, -1);
- g_string_append_printf (xml_string, "<media:keywords>%s</media:keywords>", keywords);
- g_free (keywords);
- }
+ if (priv->keywords != NULL)
+ gdata_parser_string_append_escaped (xml_string, "<media:keywords>", priv->keywords, "</media:keywords>");
}
static void
diff --git a/gdata/services/calendar/gdata-calendar-calendar.c b/gdata/services/calendar/gdata-calendar-calendar.c
index ebacbc6..0c6b05a 100644
--- a/gdata/services/calendar/gdata-calendar-calendar.c
+++ b/gdata/services/calendar/gdata-calendar-calendar.c
@@ -375,11 +375,8 @@ get_xml (GDataParsable *parsable, GString *xml_string)
GDATA_PARSABLE_CLASS (gdata_calendar_calendar_parent_class)->get_xml (parsable, xml_string);
/* Add all the Calendar-specific XML */
- if (priv->timezone != NULL) {
- gchar *_timezone = g_markup_escape_text (priv->timezone, -1);
- g_string_append_printf (xml_string, "<gCal:timezone value='%s'/>", _timezone);
- g_free (_timezone);
- }
+ if (priv->timezone != NULL)
+ gdata_parser_string_append_escaped (xml_string, "<gCal:timezone value='", priv->timezone, "'/>");
if (priv->is_hidden == TRUE)
g_string_append (xml_string, "<gCal:hidden value='true'/>");
diff --git a/gdata/services/calendar/gdata-calendar-event.c b/gdata/services/calendar/gdata-calendar-event.c
index 0261100..7db3006 100644
--- a/gdata/services/calendar/gdata-calendar-event.c
+++ b/gdata/services/calendar/gdata-calendar-event.c
@@ -669,8 +669,6 @@ get_xml (GDataParsable *parsable, GString *xml_string)
* - Finish supporting all tags
* - Check all tags here are valid for insertions and updates
* - Check things are escaped (or not) as appropriate
- * - Write a function to encapsulate g_markup_escape_text and
- * g_string_append_printf to reduce the number of allocations
*/
}
diff --git a/gdata/services/contacts/gdata-contacts-contact.c b/gdata/services/contacts/gdata-contacts-contact.c
index e0bce7c..5f58af5 100644
--- a/gdata/services/contacts/gdata-contacts-contact.c
+++ b/gdata/services/contacts/gdata-contacts-contact.c
@@ -390,8 +390,6 @@ get_xml (GDataParsable *parsable, GString *xml_string)
/* TODO:
* - Finish supporting all tags
* - Check things are escaped (or not) as appropriate
- * - Write a function to encapsulate g_markup_escape_text and
- * g_string_append_printf to reduce the number of allocations
*/
}
diff --git a/gdata/services/picasaweb/gdata-picasaweb-album.c b/gdata/services/picasaweb/gdata-picasaweb-album.c
index 19fe8f0..5586377 100644
--- a/gdata/services/picasaweb/gdata-picasaweb-album.c
+++ b/gdata/services/picasaweb/gdata-picasaweb-album.c
@@ -720,11 +720,8 @@ get_xml (GDataParsable *parsable, GString *xml_string)
/* Add all the album-specific XML */
/* TODO: gphoto:name?, gphoto:id */
- if (priv->location != NULL) {
- gchar *location = g_markup_escape_text (priv->location, -1);
- g_string_append_printf (xml_string, "<gphoto:location>%s</gphoto:location>", location);
- g_free (location);
- }
+ if (priv->location != NULL)
+ gdata_parser_string_append_escaped (xml_string, "<gphoto:location>", priv->location, "</gphoto:location>");
switch (priv->visibility) {
case GDATA_PICASAWEB_PUBLIC:
@@ -761,8 +758,6 @@ get_xml (GDataParsable *parsable, GString *xml_string)
* - Finish supporting all tags
* - Check all tags here are valid for insertions and updates
* - Check things are escaped (or not) as appropriate
- * - Write a function to encapsulate g_markup_escape_text and
- * g_string_append_printf to reduce the number of allocations
* - add GML support
*/
}
diff --git a/gdata/services/picasaweb/gdata-picasaweb-file.c b/gdata/services/picasaweb/gdata-picasaweb-file.c
index 59e0169..2bd1927 100644
--- a/gdata/services/picasaweb/gdata-picasaweb-file.c
+++ b/gdata/services/picasaweb/gdata-picasaweb-file.c
@@ -938,17 +938,11 @@ get_xml (GDataParsable *parsable, GString *xml_string)
if (priv->album_id != NULL)
g_string_append_printf (xml_string, "<gphoto:albumid>%s</gphoto:albumid>", priv->album_id);
- if (priv->client != NULL) {
- gchar *client = g_markup_escape_text (priv->client, -1);
- g_string_append_printf (xml_string, "<gphoto:client>%s</gphoto:client>", client);
- g_free (client);
- }
+ if (priv->client != NULL)
+ gdata_parser_string_append_escaped (xml_string, "<gphoto:client>", priv->client, "</gphoto:client>");
- if (priv->checksum != NULL) {
- gchar *checksum = g_markup_escape_text (priv->checksum, -1);
- g_string_append_printf (xml_string, "<gphoto:checksum>%s</gphoto:checksum>", checksum);
- g_free (checksum);
- }
+ if (priv->checksum != NULL)
+ gdata_parser_string_append_escaped (xml_string, "<gphoto:checksum>", priv->checksum, "</gphoto:checksum>");
if (priv->timestamp.tv_sec != 0 || priv->timestamp.tv_usec != 0) {
/* timestamp is in milliseconds */
@@ -979,8 +973,6 @@ get_xml (GDataParsable *parsable, GString *xml_string)
* - Finish supporting all tags
* - Check all tags here are valid for insertions and updates
* - Check things are escaped (or not) as appropriate
- * - Write a function to encapsulate g_markup_escape_text and
- * g_string_append_printf to reduce the number of allocations
*/
}
diff --git a/gdata/services/youtube/gdata-youtube-video.c b/gdata/services/youtube/gdata-youtube-video.c
index 1ba7ca4..98d1855 100644
--- a/gdata/services/youtube/gdata-youtube-video.c
+++ b/gdata/services/youtube/gdata-youtube-video.c
@@ -792,11 +792,8 @@ get_xml (GDataParsable *parsable, GString *xml_string)
/* media:group */
_gdata_parsable_get_xml (GDATA_PARSABLE (priv->media_group), xml_string, FALSE);
- if (priv->location != NULL) {
- gchar *location = g_markup_escape_text (priv->location, -1);
- g_string_append_printf (xml_string, "<yt:location>%s</yt:location>", location);
- g_free (location);
- }
+ if (priv->location != NULL)
+ gdata_parser_string_append_escaped (xml_string, "<yt:location>", priv->location, "</yt:location>");
if (priv->recorded.tv_sec != 0 || priv->recorded.tv_usec != 0) {
gchar *recorded = gdata_parser_date_from_time_val (&(priv->recorded));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]