From 3ef7d18fc0723901f80b9053f513c8051200240f Mon Sep 17 00:00:00 2001 From: Stuart Date: Wed, 1 Jun 2016 12:31:37 +0100 Subject: [PATCH] FIX Unfinished Function Declaration in Comments --- client/commonFramework/detect-unsafe-code-stream.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/client/commonFramework/detect-unsafe-code-stream.js b/client/commonFramework/detect-unsafe-code-stream.js index 14ed08f77b..ccf81a77de 100644 --- a/client/commonFramework/detect-unsafe-code-stream.js +++ b/client/commonFramework/detect-unsafe-code-stream.js @@ -5,6 +5,9 @@ window.common = (function(global) { } = global; const detectFunctionCall = /function\s*?\(|function\s+\w+\s*?\(/gi; + const detectInComment = new RegExp(['\\/\\/[\\W\\w\\s]*?function.|', + '\\/\\*[\\s\\w\\W]*?function', + '[\\s\\W\\w]*?\\*\\/'].join(''), 'gi'); const detectUnsafeJQ = /\$\s*?\(\s*?\$\s*?\)/gi; const detectUnsafeConsoleCall = /if\s\(null\)\sconsole\.log\(1\);/gi; @@ -35,7 +38,8 @@ window.common = (function(global) { if ( code.match(/function/g) && - !code.match(detectFunctionCall) + !code.match(detectFunctionCall) && + !code.match(detectInComment) ) { return Observable.throw( new Error('SyntaxError: Unsafe or unfinished function declaration')