aboutsummaryrefslogtreecommitdiff
path: root/p/api
diff options
context:
space:
mode:
Diffstat (limited to 'p/api')
-rw-r--r--p/api/index.php20
-rw-r--r--p/api/query.php12
2 files changed, 21 insertions, 11 deletions
diff --git a/p/api/index.php b/p/api/index.php
index 279826aa5..03db02188 100644
--- a/p/api/index.php
+++ b/p/api/index.php
@@ -1,12 +1,18 @@
<?php
- declare(strict_types=1);
- require dirname(__DIR__, 2) . '/constants.php';
- require LIB_PATH . '/lib_rss.php'; //Includes class autoloader
- header("Content-Security-Policy: default-src 'self'; frame-ancestors 'none'");
- header('X-Content-Type-Options: nosniff');
+declare(strict_types=1);
+require dirname(__DIR__, 2) . '/constants.php';
+require LIB_PATH . '/lib_rss.php'; //Includes class autoloader
- FreshRSS_Context::initSystem();
- Minz_Translate::init(Minz_Translate::getLanguage(null, Minz_Request::getPreferredLanguages(), null));
+FreshRSS_Context::initSystem();
+if (!FreshRSS_Context::hasSystemConf()) {
+ header('HTTP/1.1 500 Internal Server Error');
+ die('Invalid system init!');
+}
+$frameAncestors = FreshRSS_Context::systemConf()->attributeString('csp.frame-ancestors') ?? "'none'";
+header("Content-Security-Policy: default-src 'self'; frame-ancestors $frameAncestors");
+header('X-Content-Type-Options: nosniff');
+
+Minz_Translate::init(Minz_Translate::getLanguage(null, Minz_Request::getPreferredLanguages(), null));
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-GB" lang="en-GB">
diff --git a/p/api/query.php b/p/api/query.php
index 8aedd8ecf..4618f3e1b 100644
--- a/p/api/query.php
+++ b/p/api/query.php
@@ -176,12 +176,14 @@ if (($_SERVER['REQUEST_METHOD'] ?? '') === 'OPTIONS') {
if (in_array($format, ['rss', 'atom'], true)) {
header('Content-Type: application/rss+xml; charset=utf-8');
- header("Content-Security-Policy: default-src 'none'; frame-ancestors 'none'; sandbox");
+ header("Content-Security-Policy: default-src 'none'; sandbox; frame-ancestors " .
+ (FreshRSS_Context::systemConf()->attributeString('csp.frame-ancestors') ?? "'none'"));
$view->_layout(null);
$view->_path('index/rss.phtml');
} elseif (in_array($format, ['greader', 'json'], true)) {
header('Content-Type: application/json; charset=utf-8');
- header("Content-Security-Policy: default-src 'none'; frame-ancestors 'none'; sandbox");
+ header("Content-Security-Policy: default-src 'none'; sandbox; frame-ancestors " .
+ (FreshRSS_Context::systemConf()->attributeString('csp.frame-ancestors') ?? "'none'"));
$view->_layout(null);
$view->type = 'query/' . $token;
$view->list_title = $query->getName();
@@ -193,11 +195,13 @@ if (in_array($format, ['rss', 'atom'], true)) {
die();
}
header('Content-Type: application/xml; charset=utf-8');
- header("Content-Security-Policy: default-src 'none'; frame-ancestors 'none'; sandbox");
+ header("Content-Security-Policy: default-src 'none'; sandbox; frame-ancestors " .
+ (FreshRSS_Context::systemConf()->attributeString('csp.frame-ancestors') ?? "'none'"));
$view->_layout(null);
$view->_path('index/opml.phtml');
} else {
- header("Content-Security-Policy: default-src 'self'; frame-src *; img-src * data:; frame-ancestors 'none'; media-src *");
+ header("Content-Security-Policy: default-src 'self'; frame-src *; img-src * data:; media-src *; frame-ancestors " .
+ (FreshRSS_Context::systemConf()->attributeString('csp.frame-ancestors') ?? "'none'"));
$view->_layout('layout');
$view->_path('index/html.phtml');
}