Respond with bad request when MKCOL, MCALENDAR or MOVE fails

This commit is contained in:
Unrud 2017-06-09 02:30:09 +02:00 committed by Unrud
parent 48d2a33053
commit 02371685bd

View File

@ -620,7 +620,12 @@ class Application:
props["tag"] = "VCALENDAR" props["tag"] = "VCALENDAR"
# TODO: use this? # TODO: use this?
# timezone = props.get("C:calendar-timezone") # timezone = props.get("C:calendar-timezone")
try:
self.Collection.create_collection(path, props=props) self.Collection.create_collection(path, props=props)
except ValueError as e:
self.logger.warning(
"Bad MKCALENDAR request on %r: %s", path, e, exc_info=True)
return BAD_REQUEST
return client.CREATED, {}, None return client.CREATED, {}, None
def do_MKCOL(self, environ, base_prefix, path, user): def do_MKCOL(self, environ, base_prefix, path, user):
@ -638,7 +643,12 @@ class Application:
if item: if item:
return WEBDAV_PRECONDITION_FAILED return WEBDAV_PRECONDITION_FAILED
props = xmlutils.props_from_request(xml_content) props = xmlutils.props_from_request(xml_content)
try:
self.Collection.create_collection(path, props=props) self.Collection.create_collection(path, props=props)
except ValueError as e:
self.logger.warning(
"Bad MKCOL request on %r: %s", path, e, exc_info=True)
return BAD_REQUEST
return client.CREATED, {}, None return client.CREATED, {}, None
def do_MOVE(self, environ, base_prefix, path, user): def do_MOVE(self, environ, base_prefix, path, user):
@ -682,7 +692,12 @@ class Application:
if not to_collection: if not to_collection:
return WEBDAV_PRECONDITION_FAILED return WEBDAV_PRECONDITION_FAILED
to_href = posixpath.basename(to_path.strip("/")) to_href = posixpath.basename(to_path.strip("/"))
try:
self.Collection.move(item, to_collection, to_href) self.Collection.move(item, to_collection, to_href)
except ValueError as e:
self.logger.warning(
"Bad MOVE request on %r: %s", path, e, exc_info=True)
return BAD_REQUEST
return client.CREATED, {}, None return client.CREATED, {}, None
def do_OPTIONS(self, environ, base_prefix, path, user): def do_OPTIONS(self, environ, base_prefix, path, user):