Verify number of components in items
This commit is contained in:
parent
d3a90d16c3
commit
4f831de006
@ -814,7 +814,10 @@ class Application:
|
|||||||
return PRECONDITION_FAILED
|
return PRECONDITION_FAILED
|
||||||
|
|
||||||
try:
|
try:
|
||||||
items = list(vobject.readComponents(content or ""))
|
items = tuple(vobject.readComponents(content or ""))
|
||||||
|
if not write_whole_collection and len(items) != 1:
|
||||||
|
raise RuntimeError(
|
||||||
|
"Content contains %d components" % len(items))
|
||||||
for i in items:
|
for i in items:
|
||||||
storage.check_and_sanitize_item(
|
storage.check_and_sanitize_item(
|
||||||
i, is_collection=write_whole_collection, uid=item.uid
|
i, is_collection=write_whole_collection, uid=item.uid
|
||||||
|
@ -362,7 +362,11 @@ class Item:
|
|||||||
def item(self):
|
def item(self):
|
||||||
if self._item is None:
|
if self._item is None:
|
||||||
try:
|
try:
|
||||||
self._item = vobject.readOne(self._text)
|
items = tuple(vobject.readComponents(self._text))
|
||||||
|
if len(items) != 1:
|
||||||
|
raise RuntimeError(
|
||||||
|
"Content contains %d components" % len(items))
|
||||||
|
self._item = items[0]
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise RuntimeError("Failed to parse item %r from %r: %s" %
|
raise RuntimeError("Failed to parse item %r from %r: %s" %
|
||||||
(self.href, self.collection.path, e)) from e
|
(self.href, self.collection.path, e)) from e
|
||||||
|
Loading…
x
Reference in New Issue
Block a user