From 5364f1690982940bfd7d7462c7a580a97e49feb5 Mon Sep 17 00:00:00 2001 From: Lukas Reschke Date: Tue, 25 Oct 2016 14:50:00 +0200 Subject: [PATCH 1/2] Make work with nonces Required for https://github.com/nextcloud/server/pull/1871 --- js/require_config.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/js/require_config.js b/js/require_config.js index 7e90525b49..c08c576fd0 100644 --- a/js/require_config.js +++ b/js/require_config.js @@ -44,6 +44,18 @@ baseUrl: OC.linkTo('mail', 'js') }); + requirejs.createNode = function (config, moduleName) { + var node = config.xhtml ? + document.createElementNS('http://www.w3.org/1999/xhtml', 'html:script') : + document.createElement('script'); + node.type = config.scriptType || 'text/javascript'; + node.charset = 'utf-8'; + node.async = true; + + node.setAttribute("nonce", btoa(OC.requestToken)); + return node; + }; + require([ 'init' ]); From b5cc46101213f471d1a7e74d2c1dd715b01c4e7a Mon Sep 17 00:00:00 2001 From: Christoph Wurst Date: Tue, 1 Nov 2016 21:32:50 +0100 Subject: [PATCH 2/2] fix coding style --- js/require_config.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/js/require_config.js b/js/require_config.js index c08c576fd0..eb9558b246 100644 --- a/js/require_config.js +++ b/js/require_config.js @@ -10,7 +10,7 @@ * @copyright Christoph Wurst 2015, 2016 */ -(function() { +(function(OC) { 'use strict'; requirejs.config({ @@ -44,7 +44,7 @@ baseUrl: OC.linkTo('mail', 'js') }); - requirejs.createNode = function (config, moduleName) { + requirejs.createNode = function(config) { var node = config.xhtml ? document.createElementNS('http://www.w3.org/1999/xhtml', 'html:script') : document.createElement('script'); @@ -52,11 +52,11 @@ node.charset = 'utf-8'; node.async = true; - node.setAttribute("nonce", btoa(OC.requestToken)); + node.setAttribute('nonce', btoa(OC.requestToken)); return node; }; require([ 'init' ]); -})(); +})(OC);