Skip to content

Commit

Permalink
Fixing indents.
Browse files Browse the repository at this point in the history
  • Loading branch information
tamagokun committed Apr 1, 2014
1 parent 91b3212 commit 39ea834
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/Rackem/Protection/JsonCsrf.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ public function call($env)
{
list($status,$headers,$body) = $this->app->call($env);
$req = new \Rackem\Request($env);
if ($this->has_vector($req, $headers)) {
if ($this->has_vector($req, $headers)) {
$result = $this->react($env);
$this->warn($env, "attack prevented by ".get_class($this));
}
return isset($result)? $result : array($status,$headers,$body);
}
return isset($result)? $result : array($status,$headers,$body);
}

public function has_vector($req, $headers)
{
if ($req->is_xhr()) return false;

$content_type = isset($headers['Content-Type'])? explode(';',$headers['Content-Type'],2) : array('');
if(!preg_match('/^\s*application\/json\s*$/',array_shift($content_type))) return false;
$content_type = isset($headers['Content-Type'])? explode(';',$headers['Content-Type'],2) : array('');
if(!preg_match('/^\s*application\/json\s*$/',array_shift($content_type))) return false;

return $this->referrer($req->env) != $req->host();
}
Expand Down

0 comments on commit 39ea834

Please sign in to comment.