[sysadmin-bin: 131/168] Check for invalid syntax



commit 6ad91ed22bd5a2ad4e977abc3e6d45db7989adf7
Author: Olav Vitters <olav vitters nl>
Date:   Sun Apr 18 12:25:32 2010 +0200

    Check for invalid syntax
    
    Mainly due to multiple foaf:Person in one maintainer.

 semi_rdf.py   |    5 +++++
 validate-doap |    2 ++
 2 files changed, 7 insertions(+), 0 deletions(-)
---
diff --git a/semi_rdf.py b/semi_rdf.py
index 3db9dc1..513cf5d 100755
--- a/semi_rdf.py
+++ b/semi_rdf.py
@@ -33,6 +33,9 @@ WHITESPACE_RE = re.compile("\s+")
 class UrlResource(str):
     pass
 
+class ParseError(Exception):
+    pass
+
 class Node:
     def __init__(self, name, about=None):
         self.name  = name
@@ -116,6 +119,8 @@ class RdfHandler(xml.sax.handler.ContentHandler):
                 self.__node_stack.append(node)
                 self.__depth += 1
         else:
+            if not self.__object is None:
+                raise ParseError()
             node = Node(name)
             self.__node_stack.append(node)
             for attrname in attributes.getNames():
diff --git a/validate-doap b/validate-doap
index bf05c98..8ee1dee 100755
--- a/validate-doap
+++ b/validate-doap
@@ -52,6 +52,8 @@ modulename = sys.argv[1]
 
 try:
     nodes = semi_rdf.read_rdf(sys.stdin)
+except semi_rdf.ParseError, e:
+    die("Invalid RSS syntax")
 except SAXParseException, e:
     die("XML parse error (line %d): %s" % (e.getLineNumber(), e.getMessage()))
 



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