[PATCH] Add a basic date format check to DIDL-Lite parser



---
 libgupnp-av/gupnp-didl-lite-parser.c |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/libgupnp-av/gupnp-didl-lite-parser.c b/libgupnp-av/gupnp-didl-lite-parser.c
index aa2d07a..e837b9f 100644
--- a/libgupnp-av/gupnp-didl-lite-parser.c
+++ b/libgupnp-av/gupnp-didl-lite-parser.c
@@ -28,6 +28,7 @@
  */
 
 #include <string.h>
+#include <glib/gregex.h>
 #include "gupnp-av.h"
 #include "gupnp-didl-lite-object-private.h"
 #include "xml-util.h"
@@ -48,6 +49,24 @@ static guint signals[SIGNAL_LAST];
 static gboolean
 verify_didl_attributes (xmlNode *node)
 {
+    GRegex* regex;
+    const char* content;
+    gboolean result;
+
+    regex = g_regex_new("\\d\\d\\d\\d-\\d\\d-\\d\\d", (GRegexCompileFlags)0, (GRegexMatchFlags)0, NULL);
+
+    content = xml_util_get_child_element_content (node, "date");
+    if (content != NULL)
+    {
+        result = g_regex_match(regex, content, G_REGEX_MATCH_ANCHORED, NULL);
+        if (!result)
+        {
+            g_regex_unref(regex);
+            return FALSE;
+        }
+    }
+    g_regex_unref(regex);
+
     return xml_util_verify_attribute_is_boolean (node, "restricted");
 }
 
-- 
1.7.1


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