Commit 54a0e801 authored by Brion Vibber's avatar Brion Vibber

AtomPub fixes: return '201 Created' on POST of new message; better error checking on Atom input

parent 0f26d6eb
......@@ -309,9 +309,15 @@ class ApiTimelineUserAction extends ApiBareAuthAction
return;
}
$xml = file_get_contents('php://input');
$xml = trim(file_get_contents('php://input'));
if (empty($xml)) {
$this->clientError(_('Atom post must not be empty.'));
}
$dom = DOMDocument::loadXML($xml);
if (!$dom) {
$this->clientError(_('Atom post must be well-formed XML.'));
}
if ($dom->documentElement->namespaceURI != Activity::ATOM ||
$dom->documentElement->localName != 'entry') {
......@@ -349,6 +355,7 @@ class ApiTimelineUserAction extends ApiBareAuthAction
}
if (!empty($saved)) {
header('HTTP/1.1 201 Created');
header("Location: " . common_local_url('ApiStatusesShow', array('notice_id' => $saved->id,
'format' => 'atom')));
$this->showSingleAtomStatus($saved);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment