Skip to content
Snippets Groups Projects
Commit d3bb01b5 authored by Frank Karlitschek's avatar Frank Karlitschek
Browse files

more reliable host detection for reverse proxy scenarios

parent 44260a55
No related branches found
No related tags found
No related merge requests found
...@@ -376,13 +376,18 @@ class OC{ ...@@ -376,13 +376,18 @@ class OC{
// CSRF protection // CSRF protection
if(isset($_SERVER['HTTP_REFERER'])) $referer=$_SERVER['HTTP_REFERER']; else $referer=''; if(isset($_SERVER['HTTP_REFERER'])) $referer=$_SERVER['HTTP_REFERER']; else $referer='';
$protocol=OC_Helper::serverProtocol().'://'; $refererhost=parse_url($referer);
$server=$protocol.OC_Helper::serverHost(); if(isset($refererhost['host'])) $refererhost=$refererhost['host']; else $refererhost='';
if(($_SERVER['REQUEST_METHOD']=='POST') and (substr($referer,0,strlen($server))<>$server)) { $server=OC_Helper::serverHost();
$url = $protocol.OC_Helper::serverProtocol().OC::$WEBROOT.'/index.php'; $serverhost=parse_url($server);
header("Location: $url"); if(isset($serverhost['host'])) $serverhost=$serverhost['host']; else $serverhost='';
exit(); if(!self::$CLI){
} if(($_SERVER['REQUEST_METHOD']=='POST') and ($refererhost<>$serverhost)) {
$url = OC_Helper::serverProtocol().'://'.$server.OC::$WEBROOT.'/index.php';
header("Location: $url");
exit();
}
}
self::initSession(); self::initSession();
self::initTemplateEngine(); self::initTemplateEngine();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment