[rygel] server: Drop dlna: ns attributes on UpdateObject



commit 549ddb859ee49968e1d3a88d3fa12820d3afe3f0
Author: Jens Georg <jensg openismus com>
Date:   Thu Jun 6 12:48:50 2013 +0200

    server: Drop dlna: ns attributes on UpdateObject
    
    We cannot validate them and the UpdateObject action fails because of
    that, so we walk the node and remove all those attributes.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=701637

 src/librygel-server/rygel-media-object.vala |   28 +++++++++++++++++++++++++++
 1 files changed, 28 insertions(+), 0 deletions(-)
---
diff --git a/src/librygel-server/rygel-media-object.vala b/src/librygel-server/rygel-media-object.vala
index 3d6c0a4..ef5f68f 100644
--- a/src/librygel-server/rygel-media-object.vala
+++ b/src/librygel-server/rygel-media-object.vala
@@ -194,6 +194,29 @@ public abstract class Rygel.MediaObject : GLib.Object {
         this.title = didl_object.title;
     }
 
+    // Recursively drop attributes of a certain namespace from a node.
+    private void clean_node (Xml.Node* node, Xml.Ns *ns) {
+        var list = new ArrayList<string> ();
+        var attr = node->properties;
+        while (attr != null) {
+            if (attr->ns == ns) {
+                list.add (attr->name);
+            }
+
+            attr = attr->next;
+        }
+
+        foreach (var name in list) {
+            node->unset_ns_prop (ns, name);
+        }
+
+        var child = node->children;
+        while (child != null) {
+            this.clean_node (child, ns);
+            child = child->next;
+        }
+    }
+
     internal async DIDLLiteFragmentResult apply_fragments
                                         (LinkedList<string> current_fragments,
                                          LinkedList<string> new_fragments,
@@ -204,6 +227,11 @@ public abstract class Rygel.MediaObject : GLib.Object {
             var writer = new Serializer (SerializerType.GENERIC_DIDL);
             var didl_object = this.serialize (writer, http_server);
 
+            // Drop dlna:* attribute since it fails XSD validation
+            // in gupnp-av. bgo#701637
+            this.clean_node (didl_object.xml_node,
+                             didl_object.dlna_namespace);
+
             result = didl_object.apply_fragments
                                         (current_fragments.to_array (),
                                          new_fragments.to_array ());


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]