diff options
author | Zach Copley <zach@status.net> | 2009-11-30 13:08:55 -0800 |
---|---|---|
committer | Zach Copley <zach@status.net> | 2009-11-30 13:17:36 -0800 |
commit | 234e6a10b1b95b271bacd11687e1dcb168712147 (patch) | |
tree | e96e6f7fda84d5b19f25eccd9ead96e5fce99c0f /lib | |
parent | 792eb57c87c5c7e49030e4652780c0c642f58e25 (diff) |
Fix problem where screen_name and user_id parameters are being
ignored due to the router sending in '[a-zA-Z0-9]+' for the id
parameter when no id is specified as part of the URL.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api.php | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/lib/api.php b/lib/api.php index e2ea87b43..539aac4af 100644 --- a/lib/api.php +++ b/lib/api.php @@ -1142,15 +1142,10 @@ class ApiAction extends Action function getTargetUser($id) { - if (empty($id)) { + if (!preg_match('/^[a-zA-Z0-9]+$/', $id)) { // Twitter supports these other ways of passing the user ID - if (is_numeric($this->arg('id'))) { - return User::staticGet($this->arg('id')); - } else if ($this->arg('id')) { - $nickname = common_canonical_nickname($this->arg('id')); - return User::staticGet('nickname', $nickname); - } else if ($this->arg('user_id')) { + if ($this->arg('user_id')) { // This is to ensure that a non-numeric user_id still // overrides screen_name even if it doesn't get used if (is_numeric($this->arg('user_id'))) { @@ -1159,6 +1154,12 @@ class ApiAction extends Action } else if ($this->arg('screen_name')) { $nickname = common_canonical_nickname($this->arg('screen_name')); return User::staticGet('nickname', $nickname); + + } else if (is_numeric($this->arg('id'))) { + return User::staticGet($this->arg('id')); + } else if ($this->arg('id')) { + $nickname = common_canonical_nickname($this->arg('id')); + return User::staticGet('nickname', $nickname); } else { // Fall back to trying the currently authenticated user return $this->auth_user; |