]> BookStack Code Mirror - bookstack/commitdiff
Applied latest styleci changes
authorDan Brown <redacted>
Mon, 6 Sep 2021 21:19:06 +0000 (22:19 +0100)
committerDan Brown <redacted>
Mon, 6 Sep 2021 21:19:06 +0000 (22:19 +0100)
app/Http/Middleware/ApplyCspRules.php
app/Providers/AppServiceProvider.php
app/Theming/CustomHtmlHeadContentProvider.php
app/Util/CspService.php
app/Util/HtmlContentFilter.php
app/Util/HtmlNonceApplicator.php
tests/Entity/PageContentTest.php
tests/SecurityHeaderTest.php
tests/Settings/CustomHeadContentTest.php
tests/Settings/FooterLinksTest.php

index a65d12a05ca4bb54c2bb410d309a24a7882da921..6c9d14e7b6594af29c61d675533db0a78f2df271 100644 (file)
@@ -8,7 +8,6 @@ use Illuminate\Http\Request;
 
 class ApplyCspRules
 {
-
     /**
      * @var CspService
      */
@@ -43,5 +42,4 @@ class ApplyCspRules
 
         return $response;
     }
-
 }
index 1119d87df023ce4a82cf24bb0815ed8210c34bd4..59704f4a1898311aff5ed176d7c2e93955e6ed27 100644 (file)
@@ -73,7 +73,7 @@ class AppServiceProvider extends ServiceProvider
             return new SocialAuthService($app->make(SocialiteFactory::class), $app->make(LoginService::class));
         });
 
-        $this->app->singleton(CspService::class, function($app) {
+        $this->app->singleton(CspService::class, function ($app) {
             return new CspService();
         });
     }
index 6110d5a606672f7fcee6ec103432599ca06760b0..041e5d025bd8ec8ab5e21c8e9fbb883abdce6031 100644 (file)
@@ -33,9 +33,10 @@ class CustomHtmlHeadContentProvider
     {
         $content = $this->getSourceContent();
         $hash = md5($content);
-        $html = $this->cache->remember('custom-head-web:' . $hash, 86400, function() use ($content) {
+        $html = $this->cache->remember('custom-head-web:' . $hash, 86400, function () use ($content) {
             return HtmlNonceApplicator::prepare($content);
         });
+
         return HtmlNonceApplicator::apply($html, $this->cspService->getNonce());
     }
 
@@ -47,8 +48,9 @@ class CustomHtmlHeadContentProvider
     {
         $content = $this->getSourceContent();
         $hash = md5($content);
-        return $this->cache->remember('custom-head-export:' . $hash, 86400, function() use ($content) {
-             return HtmlContentFilter::removeScripts($content);
+
+        return $this->cache->remember('custom-head-export:' . $hash, 86400, function () use ($content) {
+            return HtmlContentFilter::removeScripts($content);
         });
     }
 
@@ -59,5 +61,4 @@ class CustomHtmlHeadContentProvider
     {
         return setting('app-custom-head', '');
     }
-
-}
\ No newline at end of file
+}
index 2979ebc3e1b2c3a5a793d6cd06666c73361840dd..ec5021371d7b5b998c8ac43087beef091841a5e0 100644 (file)
@@ -90,7 +90,7 @@ class CspService
     protected function getAllowedIframeHosts(): array
     {
         $hosts = config('app.iframe_hosts', '');
+
         return array_filter(explode(' ', $hosts));
     }
-
-}
\ No newline at end of file
+}
index aa395cc45c8d82d25a4c58fdb98b4c581c61d5f1..1943aa7802c81d6edb7707bc0f7d211d45514839 100644 (file)
@@ -70,6 +70,7 @@ class HtmlContentFilter
     {
         $value = strtolower($value);
         $upperVal = strtoupper($value);
+
         return 'contains(translate(' . $property . ', \'' . $upperVal . '\', \'' . $value . '\'), \'' . $value . '\')';
     }
 
index 52f334394c7b835e77a032aa0608b5ba60807e95..2653b7075477030d2291e5eb191b568b7f6c5ca4 100644 (file)
@@ -38,7 +38,7 @@ class HtmlNonceApplicator
         $returnHtml = '';
         $topElems = $doc->documentElement->childNodes->item(0)->childNodes;
         foreach ($topElems as $child) {
-            $content =  $doc->saveHTML($child);
+            $content = $doc->saveHTML($child);
             $returnHtml .= $content;
         }
 
@@ -60,5 +60,4 @@ class HtmlNonceApplicator
             $node->setAttribute('nonce', $attrValue);
         }
     }
-
 }
index 1b2ce2db2f218769e1ca2682e203909af1925679..45c27c9f9545cb4cec5b7a919a8e56d8df5a1ec4 100644 (file)
@@ -309,7 +309,7 @@ class PageContentTest extends TestCase
     {
         $checks = [
             '<svg id="test" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="100" height="100"><a xlink:href="javascript:alert(document.domain)"><rect x="0" y="0" width="100" height="100" /></a></svg>',
-            '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><use xlink:href="data:application/xml;base64 ,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIj4KPGRlZnM+CjxjaXJjbGUgaWQ9InRlc3QiIHI9IjAiIGN4PSIwIiBjeT0iMCIgc3R5bGU9ImZpbGw6ICNGMDAiPgo8c2V0IGF0dHJpYnV0ZU5hbWU9ImZpbGwiIGF0dHJpYnV0ZVR5cGU9IkNTUyIgb25iZWdpbj0nYWxlcnQoZG9jdW1lbnQuZG9tYWluKScKb25lbmQ9J2FsZXJ0KCJvbmVuZCIpJyB0bz0iIzAwRiIgYmVnaW49IjBzIiBkdXI9Ijk5OXMiIC8+CjwvY2lyY2xlPgo8L2RlZnM+Cjx1c2UgeGxpbms6aHJlZj0iI3Rlc3QiLz4KPC9zdmc+#test"/></svg>'
+            '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><use xlink:href="data:application/xml;base64 ,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIj4KPGRlZnM+CjxjaXJjbGUgaWQ9InRlc3QiIHI9IjAiIGN4PSIwIiBjeT0iMCIgc3R5bGU9ImZpbGw6ICNGMDAiPgo8c2V0IGF0dHJpYnV0ZU5hbWU9ImZpbGwiIGF0dHJpYnV0ZVR5cGU9IkNTUyIgb25iZWdpbj0nYWxlcnQoZG9jdW1lbnQuZG9tYWluKScKb25lbmQ9J2FsZXJ0KCJvbmVuZCIpJyB0bz0iIzAwRiIgYmVnaW49IjBzIiBkdXI9Ijk5OXMiIC8+CjwvY2lyY2xlPgo8L2RlZnM+Cjx1c2UgeGxpbms6aHJlZj0iI3Rlc3QiLz4KPC9zdmc+#test"/></svg>',
         ];
 
         $this->asEditor();
index fe25ef3f00b6a95de8021c7f99b53a82495a910b..2bde890ad58139ef0bc4d33416e3d4cfe68fa462 100644 (file)
@@ -125,6 +125,7 @@ class SecurityHeaderTest extends TestCase
     protected function getCspHeader(TestResponse $resp, string $type): string
     {
         $cspHeaders = collect($resp->headers->all('Content-Security-Policy'));
+
         return $cspHeaders->filter(function ($val) use ($type) {
             return strpos($val, $type) === 0;
         })->first() ?? '';
index 0e44e3ed359dd955780ec1059e304cfc24ff6c22..59d5fc06ccbe8b1ddac6cff8b98aace243de641b 100644 (file)
@@ -6,7 +6,6 @@ use Tests\TestCase;
 
 class CustomHeadContentTest extends TestCase
 {
-
     public function test_configured_content_shows_on_pages()
     {
         $this->setSettings(['app-custom-head' => '<script>console.log("cat");</script>']);
@@ -27,4 +26,4 @@ class CustomHeadContentTest extends TestCase
         $resp = $this->get('/login');
         $resp->assertSee('<div id="hello">cat</div>');
     }
-}
\ No newline at end of file
+}
index f26f809d5392b71a34045455e2cf3debc000226b..55c3e107d5ff4b071e98cf2cd50f7475a148d018 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace Tests\Settings;
+<?php
+
+namespace Tests\Settings;
 
 use Tests\TestCase;