Added check for superfluous arguments to response
This commit is contained in:
@@ -107,8 +107,9 @@ class ResponseParser:
|
||||
target_id = root.get('id')
|
||||
if not target_id:
|
||||
return ParseErrorEntry(xml, "Delete command missing required 'id' attribute", entry_id, timestamp)
|
||||
if len(root.attrib) > 1:
|
||||
return ParseErrorEntry(xml, "Delete command should only have 'id' attribute", entry_id, timestamp)
|
||||
return DeleteCommand(target_id)
|
||||
|
||||
elif root.tag == 'stop':
|
||||
# Create stop command
|
||||
return StopCommand()
|
||||
@@ -117,34 +118,46 @@ class ResponseParser:
|
||||
# Create background script entry
|
||||
if not content:
|
||||
return ParseErrorEntry(xml, "Background entry missing script content", entry_id, timestamp)
|
||||
if root.attrib:
|
||||
return ParseErrorEntry(xml, "Background entry shouldn't have attributes", entry_id, timestamp)
|
||||
return BackgroundEntry(content, entry_id, timestamp)
|
||||
|
||||
elif root.tag == 'repeat':
|
||||
# Create repeat script entry
|
||||
if not content:
|
||||
return ParseErrorEntry(xml, "Repeat entry missing script content", entry_id, timestamp)
|
||||
if root.attrib:
|
||||
return ParseErrorEntry(xml, "Repeat entry shouldn't have attributes", entry_id, timestamp)
|
||||
return RepeatEntry(content, entry_id, timestamp)
|
||||
|
||||
elif root.tag == 'single':
|
||||
# Create single shot script entry
|
||||
if not content:
|
||||
return ParseErrorEntry(xml, "Single shot entry missing script content", entry_id, timestamp)
|
||||
return ParseErrorEntry(xml, "Single entry missing script content", entry_id, timestamp)
|
||||
if root.attrib:
|
||||
return ParseErrorEntry(xml, "Single entry shouldn't have attributes", entry_id, timestamp)
|
||||
return SingleEntry(content, entry_id, timestamp)
|
||||
|
||||
elif root.tag == 'reasoning':
|
||||
# Create reasoning entry
|
||||
if not content:
|
||||
return ParseErrorEntry(xml, "Reasoning entry missing content", entry_id, timestamp)
|
||||
if root.attrib:
|
||||
return ParseErrorEntry(xml, "Reasoning entry shouldn't have attributes", entry_id, timestamp)
|
||||
return ReasoningEntry(content, entry_id, timestamp)
|
||||
|
||||
elif root.tag == 'read_stdin':
|
||||
# Create read entry - no content required
|
||||
if root.attrib:
|
||||
return ParseErrorEntry(xml, "Read stdin entry shouldn't have attributes", entry_id, timestamp)
|
||||
return ReadEntry(self.io_buffer, entry_id, timestamp)
|
||||
|
||||
elif root.tag == 'write_stdout':
|
||||
# Create write entry
|
||||
if not content:
|
||||
return ParseErrorEntry(xml, "Write entry missing content", entry_id, timestamp)
|
||||
if root.attrib:
|
||||
return ParseErrorEntry(xml, "Read stdin entry shouldn't have attributes", entry_id, timestamp)
|
||||
return WriteEntry(content, self.io_buffer, entry_id, timestamp)
|
||||
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user