Skip to content

Commit

Permalink
Revise Rest::approve_origin().
Browse files Browse the repository at this point in the history
  • Loading branch information
shadlaws committed Jun 15, 2013
1 parent 770c137 commit 53ea5a1
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions modules/rest/classes/Rest/Rest.php
Expand Up @@ -376,8 +376,10 @@ static function approve_origin($origin) {
foreach (unserialize(Module::get_var("rest", "approved_domains", array())) as $domain) {
// Check the end of the sent origin against our list. So, if "example.com" is approved,
// then "foo.example.com", "http://example.com", and "https://foo.example.com" are also
// approved.
if (substr($origin, -strlen($domain)) == $domain) {
// approved, but "badexample.com" is not.
if ((substr($origin, -strlen($domain)-1) == ".$domain") ||
(substr($origin, -strlen($domain)-1) == "/$domain") ||
($origin == $domain)) {
return $origin;
}
}
Expand Down

0 comments on commit 53ea5a1

Please sign in to comment.