瀏覽代碼

Default to SAMEORIGIN if provider_uri is Unset

Andy 4 年之前
父節點
當前提交
1877538335
共有 1 個文件被更改,包括 8 次插入4 次删除
  1. 8 4
      functions/page_header.php

+ 8 - 4
functions/page_header.php

@@ -59,10 +59,14 @@ function displayHtmlHeader( $title = 'SquirrelMail', $xtra = '', $do_hook = TRUE
 
 
     // prevent clickjack attempts
     // prevent clickjack attempts
 // FIXME: use a new config variable for this eventually. for now, we'll just cut the prefix off the provider_uri.
 // FIXME: use a new config variable for this eventually. for now, we'll just cut the prefix off the provider_uri.
-    $ancestor = $provider_uri;
-    if (strpos($ancestor, '://') !== false)
-     $ancestor = substr($ancestor, strpos($ancestor, '://') + 3);
-    $oTemplate->header('Content-Security-Policy: frame-ancestors http://'.$ancestor.' https://'.$ancestor.' http://*.'.$ancestor.' https://*.'.$ancestor);
+    if (empty($provider_uri))
+     $oTemplate->header('X-Frame-Options: SAMEORIGIN');
+    else {
+     $ancestor = $provider_uri;
+     if (strpos($ancestor, '://') !== false)
+      $ancestor = substr($ancestor, strpos($ancestor, '://') + 3);
+     $oTemplate->header('Content-Security-Policy: frame-ancestors http://'.$ancestor.' https://'.$ancestor.' http://*.'.$ancestor.' https://*.'.$ancestor);
+    }
 
 
     // prevent clickjack attempts using JavaScript for browsers that
     // prevent clickjack attempts using JavaScript for browsers that
     // don't support the X-Frame-Options header...
     // don't support the X-Frame-Options header...