]> git.joonet.de Git - adminer.git/commitdiff
Plugins: Allow changing CSP by more plugins
authorJakub Vrana <jakub@vrana.cz>
Mon, 31 Mar 2025 18:20:09 +0000 (20:20 +0200)
committerJakub Vrana <jakub@vrana.cz>
Mon, 31 Mar 2025 18:20:26 +0000 (20:20 +0200)
CHANGELOG.md
adminer/include/adminer.inc.php
adminer/include/design.inc.php
editor/include/adminer.inc.php
plugins/version-github.php

index beaac2a83b404fe072b8501e7723d96ab6a822b8..de82434d7193eb4e1154d18b125e98aa7afcac34 100644 (file)
@@ -3,6 +3,7 @@
 - Elasticsearch: Make it work with Elasticsearch 8
 - CSS: Hide menu on mobile
 - CSS: Invert icons in dark mode
+- Plugins: Allow changing CSP by more plugins
 
 ## Adminer 5.1.0 (released 2025-03-24)
 - Display collation at table structure if different from table
index 45c12430dd69a83f1358043af9bd46572610266f..d81a3a7172eb7c3aea6b9182523978471e51b20e 100644 (file)
@@ -86,10 +86,11 @@ class Adminer {
        }
 
        /** 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 {
-               return csp();
+       function csp(array $csp): array {
+               return $csp;
        }
 
        /** Print HTML code inside <head>
index 0919a5731534db435872eb7379f87e987bb93d41..a9fca3eaea97223e6228a1584841382246a1efab 100644 (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-Content-Type-Options: nosniff");
        header("Referrer-Policy: origin-when-cross-origin");
-       foreach (adminer()->csp() as $csp) {
+       foreach (adminer()->csp(csp()) as $csp) {
                $header = array();
                foreach ($csp as $key => $val) {
                        $header[] = "$key $val";
index 11df014e028f0351944fe56fb196d207ce8ab943..de9b4c99fd7004c929ab3fdd4c69ff6cc4726424 100644 (file)
@@ -59,8 +59,8 @@ class Adminer {
        function headers() {
        }
 
-       function csp() {
-               return csp();
+       function csp($csp) {
+               return $csp;
        }
 
        function head($dark = null) {
index 2b64b77e01cc841380be13fcf8b29809541f87e7..a40112eaabbdd658c9a4885ea4489b8dc435490d 100644 (file)
@@ -26,9 +26,7 @@ verifyVersion = (current, url, token) => {
 <?php
        }
 
-       function csp() {
-               $csp = Adminer\csp();
+       function csp(&$csp) {
                $csp[0]["connect-src"] .= " https://api.github.com/repos/vrana/adminer/releases/latest";
-               return $csp;
        }
 }