From cc4a12dca09dc0b9263d92026de1247d5151cbce Mon Sep 17 00:00:00 2001 From: Alexandre Roux D'Anzi Date: Tue, 11 Jan 2022 22:24:13 +0100 Subject: put carnet in a frame to avoid conflicting css --- appinfo/routes.php | 2 ++ lib/Controller/PageController.php | 30 ++++++++++++++++++-- templates/browser.php | 60 +++++++++++++++++++++++++++++++++++++++ templates/index.php | 58 ++----------------------------------- 4 files changed, 92 insertions(+), 58 deletions(-) create mode 100755 templates/browser.php diff --git a/appinfo/routes.php b/appinfo/routes.php index d1c3226..f42e891 100755 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -13,6 +13,8 @@ return [ 'routes' => [ ['name' => 'page#index', 'url' => '/', 'verb' => 'GET'], ['name' => 'page#writer', 'url' => '/writer', 'verb' => 'GET'], + ['name' => 'page#browser', 'url' => '/browser', 'verb' => 'GET'], + ['name' => 'page#importer', 'url' => '/importer', 'verb' => 'GET'], ['name' => 'page#exporter', 'url' => 'exporter/exporter.html', 'verb' => 'GET'], diff --git a/lib/Controller/PageController.php b/lib/Controller/PageController.php index 9aa126b..e3f758a 100755 --- a/lib/Controller/PageController.php +++ b/lib/Controller/PageController.php @@ -17,6 +17,32 @@ class PageController extends Controller { $this->config = $Config; } + /** + * CAUTION: the @Stuff turns off security checks; for this page no admin is + * required and no CSRF check. If you don't know what CSRF is, read + * it up in the docs or you might create a security hole. This is + * basically the only required method to add this exemption, don't + * add it to any other method if you don't exactly know what it does + * + * @NoAdminRequired + * @NoCSRFRequired + */ + public function browser() { + $parameters = [ + 'nc_version' => \OCP\Util::getVersion()[0], + 'carnet_display_fullscreen' => $this->config->getAppValue('carnet', 'carnetDisplayFullscreen', 'no'), + 'app_version' => App::getAppInfo($this->appName)['version'], + ]; + $response = new TemplateResponse($this->appName,"browser",$parameters); + $response->renderAs("blank"); + $policy = new ContentSecurityPolicy(); + $policy->addAllowedFrameDomain('\'self\''); + $policy->addAllowedFrameDomain('data:'); + + $response->setContentSecurityPolicy($policy); // allow iframe + return $response; + } + /** * CAUTION: the @Stuff turns off security checks; for this page no admin is * required and no CSRF check. If you don't know what CSRF is, read @@ -34,12 +60,10 @@ class PageController extends Controller { 'app_version' => App::getAppInfo($this->appName)['version'], ]; $response = new TemplateResponse($this->appName,"index",$parameters); - if($this->config->getAppValue('carnet', 'carnetDisplayFullscreen', 'no') === "yes") - $response->renderAs("blank"); $policy = new ContentSecurityPolicy(); $policy->addAllowedFrameDomain('\'self\''); $policy->addAllowedFrameDomain('data:'); - + $response->setContentSecurityPolicy($policy); // allow iframe return $response; } diff --git a/templates/browser.php b/templates/browser.php new file mode 100755 index 0000000..19a5770 --- /dev/null +++ b/templates/browser.php @@ -0,0 +1,60 @@ +"; + +$file .= "".$_['requesttoken'].""; +if($_['carnet_display_fullscreen']==="yes"){ + + $file = str_replace('', " + + + getColorPrimary()."\"> + + ", $file); + if($_['nc_version']>=16) + style("carnet","../templates/CarnetElectron/compatibility/nextcloud/nc16"); + +} +else { + if($_['nc_version']>=14) + style("carnet","../templates/CarnetElectron/compatibility/nextcloud/nc14-header"); +} +$nonce = ""; +if (method_exists(\OC::$server, "getContentSecurityPolicyNonceManager")){ + $nonce = \OC::$server->getContentSecurityPolicyNonceManager()->getNonce(); +} +else{ + style("carnet","../templates/CarnetElectron/compatibility/nextcloud/owncloud"); +} + +$file = str_replace("src=\"","defer nonce='".$nonce."' src=\"".$root."/CarnetElectron/",$file); +echo $file; +echo "".$root."/CarnetElectron/"; +?> \ No newline at end of file diff --git a/templates/index.php b/templates/index.php index 6109860..c3ae8cc 100755 --- a/templates/index.php +++ b/templates/index.php @@ -1,59 +1,7 @@ -$file = preg_replace_callback('/ - if($matches[2] === "libs/jquery.min.js" AND $fullscreen === "no") - return " - ", $file); - if($_['nc_version']>=16) - style("carnet","../templates/CarnetElectron/compatibility/nextcloud/nc16"); - -} -else { - if($_['nc_version']>=14) - style("carnet","../templates/CarnetElectron/compatibility/nextcloud/nc14-header"); -} -$nonce = ""; -if (method_exists(\OC::$server, "getContentSecurityPolicyNonceManager")){ - $nonce = \OC::$server->getContentSecurityPolicyNonceManager()->getNonce(); -} -else{ - style("carnet","../templates/CarnetElectron/compatibility/nextcloud/owncloud"); -} - -$file = str_replace("src=\"","defer nonce='".$nonce."' src=\"".$root."/CarnetElectron/",$file); -echo $file; -echo "".$root."/CarnetElectron/"; -?> \ No newline at end of file + \ No newline at end of file -- cgit v1.2.3 From 4dea0cc834d98bb80a45575e3096b94be08d1341 Mon Sep 17 00:00:00 2001 From: Alexandre Roux D'Anzi Date: Sun, 23 Jan 2022 18:39:36 +0100 Subject: Carnet is now in an iframe to avoid style conflicts --- appinfo/info.xml | 4 ++-- lib/Controller/PageController.php | 3 +-- templates/CarnetElectron | 2 +- templates/index.php | 0 templates/settings.php | 2 +- 5 files changed, 5 insertions(+), 6 deletions(-) mode change 160000 => 120000 templates/CarnetElectron mode change 100755 => 100644 templates/index.php diff --git a/appinfo/info.xml b/appinfo/info.xml index 7c50f9d..188dc50 100755 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -19,7 +19,7 @@ Mac, with sync capabilities - Statistics : words/sentences/characters - Sync with ownCloud/NextCloud - Online editor as a ownCloud/NextCloud App]]> - 0.24.2 + 0.24.3 agpl Phie Carnet @@ -33,7 +33,7 @@ Mac, with sync capabilities - + diff --git a/lib/Controller/PageController.php b/lib/Controller/PageController.php index e3f758a..e8ee548 100755 --- a/lib/Controller/PageController.php +++ b/lib/Controller/PageController.php @@ -101,8 +101,7 @@ class PageController extends Controller { 'app_version' => App::getAppInfo($this->appName)['version'], ]; $response = new TemplateResponse($this->appName,"settings", $parameters); - if($this->config->getAppValue('carnet', 'carnetDisplayFullscreen', 'no') === "yes") - $response->renderAs("blank"); + $response->renderAs("blank"); $policy = new ContentSecurityPolicy(); $policy->addAllowedFrameDomain('\'self\''); $response->setContentSecurityPolicy($policy); // allow iframe diff --git a/templates/CarnetElectron b/templates/CarnetElectron deleted file mode 160000 index 7800759..0000000 --- a/templates/CarnetElectron +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 78007590a7fca55fd381f91af94f52a4dc619a5c diff --git a/templates/CarnetElectron b/templates/CarnetElectron new file mode 120000 index 0000000..5b71014 --- /dev/null +++ b/templates/CarnetElectron @@ -0,0 +1 @@ +/home/phieubuntu/Dev/Code/Carnet/CarnetElectron \ No newline at end of file diff --git a/templates/index.php b/templates/index.php old mode 100755 new mode 100644 diff --git a/templates/settings.php b/templates/settings.php index 1d4396e..c7d2a73 100755 --- a/templates/settings.php +++ b/templates/settings.php @@ -1,7 +1,7 @@