From 4be714aa97086628707614e02d26123f65292755 Mon Sep 17 00:00:00 2001 From: benmcmahon100 Date: Mon, 3 Aug 2015 18:02:26 +0100 Subject: [PATCH] Generalised RegEx for waypoint-make-it-functional fix https://github.com/FreeCodeCamp/freecodecamp/issues/1476 added comment to show where to block exploits in jsframework --- public/js/lib/coursewares/coursewaresJSFramework_0.0.6.js | 1 + seed/challenges/basic-javascript.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/public/js/lib/coursewares/coursewaresJSFramework_0.0.6.js b/public/js/lib/coursewares/coursewaresJSFramework_0.0.6.js index 0710e4ee6e..564b9decae 100644 --- a/public/js/lib/coursewares/coursewaresJSFramework_0.0.6.js +++ b/public/js/lib/coursewares/coursewaresJSFramework_0.0.6.js @@ -211,6 +211,7 @@ var runTests = function(err, data) { }]; createTestDisplay(); } + //Add blocks to test exploits here! else if(editorValue.match(/if\s\(null\)\sconsole\.log\(1\);/gi)){ allTestsPassed = false; userTests = [{ diff --git a/seed/challenges/basic-javascript.json b/seed/challenges/basic-javascript.json index d444d15902..92cb7d80e1 100644 --- a/seed/challenges/basic-javascript.json +++ b/seed/challenges/basic-javascript.json @@ -647,7 +647,7 @@ "Let's try creating and calling a function now called myFunction" ], "tests":[ - "assert((function(){if(typeof(f) !== 'undefined' && typeof(f) === 'number' && f === a + b && editor.getValue().match(RegExp('return\\\\(a\\\\+b\\\\)', 'g')).length >= 1){return(true);}else{return(false);}})(), 'Your function should return the value of a + b');" + "assert((function(){if(typeof(f) !== 'undefined' && typeof(f) === 'number' && f === a + b && editor.getValue().match(/return/gi).length >= 1 && editor.getValue().match(/a/gi).length >= 1 && editor.getValue().match(/b/gi).length >= 1 && editor.getValue().match(/\\+/gi).length >= 1){return(true);}else{return(false);}})(), 'Your function should return the value of a + b');" ], "challengeSeed":[ "var a = 4;",