From 6dbe417c51125419516dd29ebe4e529926c41a0f Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Tue, 25 Oct 2016 21:36:37 +0200 Subject: [PATCH] Inlince oc.js if possible! Signed-off-by: Roeland Jago Douma --- core/templates/layout.base.php | 5 +++++ core/templates/layout.guest.php | 5 +++++ core/templates/layout.user.php | 5 +++++ lib/private/TemplateLayout.php | 18 +++++++++++++++++- 4 files changed, 32 insertions(+), 1 deletion(-) diff --git a/core/templates/layout.base.php b/core/templates/layout.base.php index 3f13523afcb..d6d70f31362 100644 --- a/core/templates/layout.base.php +++ b/core/templates/layout.base.php @@ -18,6 +18,11 @@ + + + diff --git a/core/templates/layout.guest.php b/core/templates/layout.guest.php index 6d46ac6cf2c..1692e4268d4 100644 --- a/core/templates/layout.guest.php +++ b/core/templates/layout.guest.php @@ -19,6 +19,11 @@ + + + diff --git a/core/templates/layout.user.php b/core/templates/layout.user.php index d258e3582d0..bc8edf085d0 100644 --- a/core/templates/layout.user.php +++ b/core/templates/layout.user.php @@ -26,6 +26,11 @@ + + + diff --git a/lib/private/TemplateLayout.php b/lib/private/TemplateLayout.php index 92d861238c3..9f89174e7f9 100644 --- a/lib/private/TemplateLayout.php +++ b/lib/private/TemplateLayout.php @@ -43,6 +43,7 @@ use Assetic\Filter\CssMinFilter; use Assetic\Filter\CssRewriteFilter; use Assetic\Filter\JSqueezeFilter; use Assetic\Filter\SeparatorFilter; +use OC\Template\JSConfigHelper; class TemplateLayout extends \OC_Template { @@ -142,7 +143,22 @@ class TemplateLayout extends \OC_Template { $jsFiles = self::findJavascriptFiles(\OC_Util::$scripts); $this->assign('jsfiles', array()); if ($this->config->getSystemValue('installed', false) && $renderAs != 'error') { - $this->append( 'jsfiles', \OC::$server->getURLGenerator()->linkToRoute('core.OCJS.getConfig', ['v' => self::$versionHash])); + if (\OC::$server->getContentSecurityPolicyNonceManager()->browserSupportsCspV3()) { + $jsConfigHelper = new JSConfigHelper( + \OC::$server->getL10N('core'), + \OC::$server->getThemingDefaults(), + \OC::$server->getAppManager(), + \OC::$server->getUserSession()->getUser(), + \OC::$server->getConfig(), + \OC::$server->getGroupManager(), + \OC::$server->getIniWrapper(), + \OC::$server->getURLGenerator() + ); + $this->assign('inline_ocjs', $jsConfigHelper->getConfig()); + $this->assign('foo', 'bar'); + } else { + $this->append('jsfiles', \OC::$server->getURLGenerator()->linkToRoute('core.OCJS.getConfig', ['v' => self::$versionHash])); + } } foreach($jsFiles as $info) { $web = $info[1];