summaryrefslogtreecommitdiff
path: root/gdata/media
diff options
context:
space:
mode:
authorPhilip Withnall <philip@tecnocode.co.uk>2011-04-15 17:54:29 +0100
committerPhilip Withnall <philip@tecnocode.co.uk>2011-04-15 18:41:30 +0100
commit23571a59e1d4b4dffc1079252f5a8bbe81c249c5 (patch)
tree60001ac2262b6cc32194fa718201b8a2dc56f906 /gdata/media
parent9d2e6d49ee144b05a7a46258f6d82ef92fcbe091 (diff)
downloadlibgdata-23571a59e1d4b4dffc1079252f5a8bbe81c249c5.tar.gz
media: Handle media:rating elements which don't provide a country attribute
Includes a test case.
Diffstat (limited to 'gdata/media')
-rw-r--r--gdata/media/gdata-media-group.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/gdata/media/gdata-media-group.c b/gdata/media/gdata-media-group.c
index c046bb53..94bf01e0 100644
--- a/gdata/media/gdata-media-group.c
+++ b/gdata/media/gdata-media-group.c
@@ -195,16 +195,24 @@ parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_da
} else if (xmlStrcmp (node->name, (xmlChar*) "rating") == 0) {
/* media:rating */
xmlChar *countries;
- gchar **country_list, **country;
countries = xmlGetProp (node, (xmlChar*) "country");
- country_list = g_strsplit ((const gchar*) countries, ",", -1);
- xmlFree (countries);
- /* Add all the listed countries to the restricted countries table */
- for (country = country_list; *country != NULL; country++)
- g_hash_table_insert (self->priv->restricted_countries, *country, GUINT_TO_POINTER (TRUE));
- g_free (country_list);
+ if (countries != NULL) {
+ gchar **country_list, **country;
+
+ /* It's either a comma-separated list of countries, or the value "all" */
+ country_list = g_strsplit ((const gchar*) countries, ",", -1);
+ xmlFree (countries);
+
+ /* Add all the listed countries to the restricted countries table */
+ for (country = country_list; *country != NULL; country++)
+ g_hash_table_insert (self->priv->restricted_countries, *country, GUINT_TO_POINTER (TRUE));
+ g_free (country_list);
+ } else {
+ /* Assume it's restricted in all countries */
+ g_hash_table_insert (self->priv->restricted_countries, g_strdup ("all"), GUINT_TO_POINTER (TRUE));
+ }
} else if (xmlStrcmp (node->name, (xmlChar*) "restriction") == 0) {
/* media:restriction */
xmlChar *type, *countries, *relationship;