[libgdata] youtube: Fix attribute escaping for GDataYouTubeVideo
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgdata] youtube: Fix attribute escaping for GDataYouTubeVideo
- Date: Thu, 2 Dec 2010 18:08:59 +0000 (UTC)
commit a672b202e53fb46ddb9793d5d2cdfc43e55895f6
Author: Philip Withnall <philip tecnocode co uk>
Date: Thu Dec 2 18:07:06 2010 +0000
youtube: Fix attribute escaping for GDataYouTubeVideo
Closes: bgo#631033
gdata/services/youtube/gdata-youtube-video.c | 4 +-
gdata/tests/youtube.c | 38 ++++++++++++++++++++++++++
2 files changed, 40 insertions(+), 2 deletions(-)
---
diff --git a/gdata/services/youtube/gdata-youtube-video.c b/gdata/services/youtube/gdata-youtube-video.c
index d3cb1a3..5bc7929 100644
--- a/gdata/services/youtube/gdata-youtube-video.c
+++ b/gdata/services/youtube/gdata-youtube-video.c
@@ -788,7 +788,8 @@ access_control_cb (const gchar *action, gpointer value, GString *xml_string)
g_assert_not_reached ();
}
- g_string_append_printf (xml_string, "<yt:accessControl action='%s' permission='%s'/>", action, permission_string);
+ gdata_parser_string_append_escaped (xml_string, "<yt:accessControl action='", action, "'");
+ g_string_append_printf (xml_string, " permission='%s'/>", permission_string);
}
static void
@@ -819,7 +820,6 @@ get_xml (GDataParsable *parsable, GString *xml_string)
/* TODO:
* - georss:where
- * - Check things are escaped (or not) as appropriate
*/
}
diff --git a/gdata/tests/youtube.c b/gdata/tests/youtube.c
index c9e1f33..f1d84e6 100644
--- a/gdata/tests/youtube.c
+++ b/gdata/tests/youtube.c
@@ -699,6 +699,42 @@ test_parsing_comments_feed_link (void)
}*/
static void
+test_video_escaping (void)
+{
+ GDataYouTubeVideo *video;
+ gchar *xml;
+ const gchar * const keywords[] = { "<keyword1>", "keyword2 & stuff, things", NULL };
+
+ video = gdata_youtube_video_new (NULL);
+ gdata_youtube_video_set_location (video, "Here & there");
+ gdata_youtube_video_set_access_control (video, "<action>", GDATA_YOUTUBE_PERMISSION_ALLOWED);
+ gdata_youtube_video_set_keywords (video, keywords);
+ gdata_youtube_video_set_description (video, "Description & stuff.");
+ gdata_youtube_video_set_aspect_ratio (video, "4 & 3");
+
+ /* Check the outputted XML is escaped properly */
+ xml = gdata_parsable_get_xml (GDATA_PARSABLE (video));
+ g_assert_cmpstr (xml, ==,
+ "<?xml version='1.0' encoding='UTF-8'?>"
+ "<entry xmlns='http://www.w3.org/2005/Atom' xmlns:media='http://search.yahoo.com/mrss/' "
+ "xmlns:gd='http://schemas.google.com/g/2005' "
+ "xmlns:yt='http://gdata.youtube.com/schemas/2007' xmlns:app='http://www.w3.org/2007/app'>"
+ "<title type='text'></title>"
+ "<category term='http://gdata.youtube.com/schemas/2007#video' scheme='http://schemas.google.com/g/2005#kind'/>"
+ "<media:group>"
+ "<media:description type='plain'>Description & stuff.</media:description>"
+ "<media:keywords><keyword1>,keyword2 & stuff%2C things</media:keywords>"
+ "<yt:aspectratio>4 & 3</yt:aspectratio>"
+ "</media:group>"
+ "<yt:location>Here & there</yt:location>"
+ "<yt:accessControl action='<action>' permission='allowed'/>"
+ "<app:control><app:draft>no</app:draft></app:control>"
+ "</entry>");
+ g_free (xml);
+ g_object_unref (video);
+}
+
+static void
test_query_uri (void)
{
gdouble latitude, longitude, radius;
@@ -1161,6 +1197,8 @@ main (int argc, char *argv[])
g_test_add_func ("/youtube/parsing/yt:category", test_parsing_yt_category);
g_test_add_func ("/youtube/parsing/video_id_from_uri", test_parsing_video_id_from_uri);
+ g_test_add_func ("/youtube/video/escaping", test_video_escaping);
+
g_test_add_func ("/youtube/query/uri", test_query_uri);
g_test_add_func ("/youtube/query/etag", test_query_etag);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]