1
0
mirror of https://github.com/vrana/adminer.git synced 2025-08-06 06:37:33 +02:00

Plugins: Allow changing CSP by more plugins

This commit is contained in:
Jakub Vrana
2025-03-31 20:20:09 +02:00
parent 595c228175
commit 9f3f3b9515
5 changed files with 9 additions and 9 deletions

View File

@@ -3,6 +3,7 @@
- Elasticsearch: Make it work with Elasticsearch 8 - Elasticsearch: Make it work with Elasticsearch 8
- CSS: Hide menu on mobile - CSS: Hide menu on mobile
- CSS: Invert icons in dark mode - CSS: Invert icons in dark mode
- Plugins: Allow changing CSP by more plugins
## Adminer 5.1.0 (released 2025-03-24) ## Adminer 5.1.0 (released 2025-03-24)
- Display collation at table structure if different from table - Display collation at table structure if different from table

View File

@@ -86,10 +86,11 @@ class Adminer {
} }
/** Get Content Security Policy headers /** Get Content Security Policy headers
* @return list<string[]> of arrays with directive name in key, allowed sources in value * @param list<string[]> $csp of arrays with directive name in key, allowed sources in value
* @return list<string[]> same as $csp
*/ */
function csp(): array { function csp(array $csp): array {
return csp(); return $csp;
} }
/** Print HTML code inside <head> /** Print HTML code inside <head>

View File

@@ -133,7 +133,7 @@ function page_headers(): void {
header("X-XSS-Protection: 0"); // prevents introducing XSS in IE8 by removing safe parts of the page header("X-XSS-Protection: 0"); // prevents introducing XSS in IE8 by removing safe parts of the page
header("X-Content-Type-Options: nosniff"); header("X-Content-Type-Options: nosniff");
header("Referrer-Policy: origin-when-cross-origin"); header("Referrer-Policy: origin-when-cross-origin");
foreach (adminer()->csp() as $csp) { foreach (adminer()->csp(csp()) as $csp) {
$header = array(); $header = array();
foreach ($csp as $key => $val) { foreach ($csp as $key => $val) {
$header[] = "$key $val"; $header[] = "$key $val";

View File

@@ -59,8 +59,8 @@ class Adminer {
function headers() { function headers() {
} }
function csp() { function csp($csp) {
return csp(); return $csp;
} }
function head($dark = null) { function head($dark = null) {

View File

@@ -26,9 +26,7 @@ verifyVersion = (current, url, token) => {
<?php <?php
} }
function csp() { function csp(&$csp) {
$csp = Adminer\csp();
$csp[0]["connect-src"] .= " https://api.github.com/repos/vrana/adminer/releases/latest"; $csp[0]["connect-src"] .= " https://api.github.com/repos/vrana/adminer/releases/latest";
return $csp;
} }
} }