[libgdata] core: Fix attribute escaping for GDataFeed
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgdata] core: Fix attribute escaping for GDataFeed
- Date: Fri, 10 Dec 2010 17:54:43 +0000 (UTC)
commit 6a728e3d24f446934bd36f7687d841540ada08f6
Author: Philip Withnall <philip tecnocode co uk>
Date: Fri Dec 10 17:51:41 2010 +0000
core: Fix attribute escaping for GDataFeed
Helps: bgo#631033
gdata/gdata-feed.c | 2 +-
gdata/tests/general.c | 32 ++++++++++++++++++++++++++++++++
2 files changed, 33 insertions(+), 1 deletions(-)
---
diff --git a/gdata/gdata-feed.c b/gdata/gdata-feed.c
index c270f42..dd3b6e0 100644
--- a/gdata/gdata-feed.c
+++ b/gdata/gdata-feed.c
@@ -556,7 +556,7 @@ get_xml (GDataParsable *parsable, GString *xml_string)
/* NOTE: Only the required elements are implemented at the moment */
gdata_parser_string_append_escaped (xml_string, "<title type='text'>", priv->title, "</title>");
- g_string_append_printf (xml_string, "<id>%s</id>", priv->id);
+ gdata_parser_string_append_escaped (xml_string, "<id>", priv->id, "</id>");
updated = gdata_parser_int64_to_iso8601 (priv->updated);
g_string_append_printf (xml_string, "<updated>%s</updated>", updated);
diff --git a/gdata/tests/general.c b/gdata/tests/general.c
index 34b7391..a505098 100644
--- a/gdata/tests/general.c
+++ b/gdata/tests/general.c
@@ -668,6 +668,37 @@ test_feed_error_handling (void)
}
static void
+test_feed_escaping (void)
+{
+ GDataFeed *feed;
+ gchar *xml;
+ GError *error = NULL;
+
+ /* Since we can't construct a GDataEntry directly, we need to parse it from XML */
+ feed = GDATA_FEED (gdata_parsable_new_from_xml (GDATA_TYPE_FEED,
+ "<?xml version='1.0' encoding='UTF-8'?>"
+ "<feed xmlns='http://www.w3.org/2005/Atom'>"
+ "<id>http://foo.com?foo&bar</id>"
+ "<updated>2010-12-10T17:49:15Z</updated>"
+ "<title type='text'>Test feed & stuff.</title>"
+ "</feed>", -1, &error));
+ g_assert_no_error (error);
+ g_assert (GDATA_IS_FEED (feed));
+
+ /* Check the outputted XML is escaped properly */
+ xml = gdata_parsable_get_xml (GDATA_PARSABLE (feed));
+ g_assert_cmpstr (xml, ==,
+ "<?xml version='1.0' encoding='UTF-8'?>"
+ "<feed xmlns='http://www.w3.org/2005/Atom'>"
+ "<title type='text'>Test feed & stuff.</title>"
+ "<id>http://foo.com?foo&bar</id>"
+ "<updated>2010-12-10T17:49:15Z</updated>"
+ "</feed>");
+ g_free (xml);
+ g_object_unref (feed);
+}
+
+static void
test_query_categories (void)
{
GDataQuery *query;
@@ -3628,6 +3659,7 @@ main (int argc, char *argv[])
g_test_add_func ("/feed/parse_xml", test_feed_parse_xml);
g_test_add_func ("/feed/error_handling", test_feed_error_handling);
+ g_test_add_func ("/feed/escaping", test_feed_escaping);
g_test_add_func ("/query/categories", test_query_categories);
g_test_add_func ("/query/unicode", test_query_unicode);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]