[gupnp-av] Roughly verify passed date in DIDL
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gupnp-av] Roughly verify passed date in DIDL
- Date: Mon, 11 Jul 2011 08:14:48 +0000 (UTC)
commit b39ac3ac8a521f3bc7ce95536c4095ffef479927
Author: Jens Georg <mail jensge org>
Date: Mon Jul 11 10:12:19 2011 +0200
Roughly verify passed date in DIDL
libgupnp-av/gupnp-didl-lite-parser.c | 26 +++++++++++++++++++++++++-
1 files changed, 25 insertions(+), 1 deletions(-)
---
diff --git a/libgupnp-av/gupnp-didl-lite-parser.c b/libgupnp-av/gupnp-didl-lite-parser.c
index aa2d07a..d7ab045 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 <ctype.h>
#include "gupnp-av.h"
#include "gupnp-didl-lite-object-private.h"
#include "xml-util.h"
@@ -48,7 +49,30 @@ static guint signals[SIGNAL_LAST];
static gboolean
verify_didl_attributes (xmlNode *node)
{
- return xml_util_verify_attribute_is_boolean (node, "restricted");
+ const char *content;
+
+ content = xml_util_get_child_element_content (node, "date");
+ if (content) {
+ /* try to roughly verify the passed date with ^\d{4}-\d{2}-\d{2} */
+ char *ptr = (char *) content;
+ int state = 0;
+ while (*ptr) {
+ if (state == 4 || state == 7) {
+ if (*ptr != '-')
+ return FALSE;
+ } else {
+ if (!isdigit (*ptr))
+ return FALSE;
+ }
+
+ ptr++;
+ state++;
+ if (state == 10)
+ break;
+ }
+ }
+
+ return xml_util_verify_attribute_is_boolean (node, "restricted");
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]