core: Don't allow comments in DIDL-Lite
authorZeeshan Ali (Khattak) <zeeshanak@gnome.org>
Wed, 26 May 2010 20:54:21 +0000 (23:54 +0300)
committerZeeshan Ali (Khattak) <zeeshanak@gnome.org>
Wed, 2 Jun 2010 12:11:58 +0000 (15:11 +0300)
Don't allow comments in DIDL-Lite in 'Elements' argument of CreatObject.

src/rygel/rygel-item-creator.vala

index e656d2e..dd943c5 100644 (file)
@@ -30,6 +30,8 @@ private errordomain Rygel.ItemCreatorError {
  * CreateObject action implementation.
  */
 internal class Rygel.ItemCreator: GLib.Object, Rygel.StateMachine {
+    private static PatternSpec comment_pattern = new PatternSpec ("*<!--*-->*");
+
     // In arguments
     public string container_id;
     public string elements;
@@ -94,6 +96,9 @@ internal class Rygel.ItemCreator: GLib.Object, Rygel.StateMachine {
         if (this.elements == null) {
             throw new ContentDirectoryError.BAD_METADATA (
                                         _("'Elements' argument missing."));
+        } else if (comment_pattern.match_string (this.elements)) {
+            throw new ContentDirectoryError.BAD_METADATA (
+                                        _("Comments not allowed in XML"));
         }
 
         if (this.container_id == null) {