Commit e16cb8c0 authored by Evan Prodromou's avatar Evan Prodromou

Merge branch '0.9.x' into righttoleave

parents d840578a 0330bad6
......@@ -165,7 +165,7 @@ class ApiStatusesShowAction extends ApiPrivateAuthAction
}
/**
* Is this action read only?
* We expose AtomPub here, so non-GET/HEAD reqs must be read/write.
*
* @param array $args other arguments
*
......@@ -174,11 +174,7 @@ class ApiStatusesShowAction extends ApiPrivateAuthAction
function isReadOnly($args)
{
if ($_SERVER['REQUEST_METHOD'] == 'GET') {
return true;
} else {
return false;
}
return ($_SERVER['REQUEST_METHOD'] == 'GET' || $_SERVER['REQUEST_METHOD'] == 'HEAD');
}
/**
......
......@@ -235,7 +235,7 @@ class ApiTimelineUserAction extends ApiBareAuthAction
}
/**
* Is this action read only?
* We expose AtomPub here, so non-GET/HEAD reqs must be read/write.
*
* @param array $args other arguments
*
......@@ -244,11 +244,7 @@ class ApiTimelineUserAction extends ApiBareAuthAction
function isReadOnly($args)
{
if ($_SERVER['REQUEST_METHOD'] == 'GET') {
return true;
} else {
return false;
}
return ($_SERVER['REQUEST_METHOD'] == 'GET' || $_SERVER['REQUEST_METHOD'] == 'HEAD');
}
/**
......@@ -309,9 +305,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,7 +351,8 @@ class ApiTimelineUserAction extends ApiBareAuthAction
}
if (!empty($saved)) {
header("Location: " . common_local_url('ApiStatusesShow', array('notice_id' => $saved->id,
header('HTTP/1.1 201 Created');
header("Location: " . common_local_url('ApiStatusesShow', array('id' => $saved->id,
'format' => 'atom')));
$this->showSingleAtomStatus($saved);
}
......
......@@ -215,4 +215,15 @@ class OembedAction extends Action
return;
}
/**
* Is this action read-only?
*
* @param array $args other arguments
*
* @return boolean is read only action?
*/
function isReadOnly($args)
{
return true;
}
}
......@@ -907,8 +907,8 @@ class Router
// AtomPub API
$m->connect('api/statusnet/app/service/:id.xml',
array('action' => 'ApiAtomService',
'id' => Nickname::DISPLAY_FMT));
array('action' => 'ApiAtomService'),
array('id' => Nickname::DISPLAY_FMT));
$m->connect('api/statusnet/app/service.xml',
array('action' => 'ApiAtomService'));
......
......@@ -145,4 +145,16 @@ class XrdAction extends Action
return (substr($uri, 0, 5) == 'acct:');
}
/**
* Is this action read-only?
*
* @param array $args other arguments
*
* @return boolean is read only action?
*/
function isReadOnly($args)
{
return true;
}
}
......@@ -165,4 +165,16 @@ class AutocompleteAction extends Action
print json_encode($result) . "\n";
}
}
/**
* Is this action read-only?
*
* @param array $args other arguments
*
* @return boolean is read only action?
*/
function isReadOnly($args)
{
return true;
}
}
......@@ -1552,8 +1552,11 @@ class Ostatus_profile extends Memcached_DataObject
}
// Try the profile url (like foo.example.com or example.com/user/foo)
$profileUrl = ($object->link) ? $object->link : $hints['profileurl'];
if (!empty($object->link)) {
$profileUrl = $object->link;
} else if (!empty($hints['profileurl'])) {
$profileUrl = $hints['profileurl'];
}
if (!empty($profileUrl)) {
$nickname = self::nicknameFromURI($profileUrl);
......@@ -1584,9 +1587,11 @@ class Ostatus_profile extends Memcached_DataObject
protected static function nicknameFromURI($uri)
{
preg_match('/(\w+):/', $uri, $matches);
$protocol = $matches[1];
if (preg_match('/(\w+):/', $uri, $matches)) {
$protocol = $matches[1];
} else {
return null;
}
switch ($protocol) {
case 'acct':
......
This diff is collapsed.
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