1
0
mirror of https://github.com/chinchang/web-maker.git synced 2025-07-14 18:46:19 +02:00

fix loop protection for ts and es6 code

This commit is contained in:
Kushagra Gour
2017-04-02 15:08:41 +05:30
parent 51d7bfbf6f
commit 699e835204
2 changed files with 3 additions and 3 deletions

View File

@ -626,7 +626,7 @@ onboardDontShowInTabOptionBtn, TextareaAutoComplete, savedItemCountEl, indentati
showErrors('js', [ { lineNumber: e.location.first_line, message: e.message } ]); showErrors('js', [ { lineNumber: e.location.first_line, message: e.message } ]);
} finally { } finally {
if (shouldPreventInfiniteLoops !== false) { if (shouldPreventInfiniteLoops !== false) {
code = utils.addInfiniteLoopProtection(code); code = utils.addInfiniteLoopProtection(coffeeCode);
} }
d.resolve(code); d.resolve(code);
} }
@ -674,7 +674,7 @@ onboardDontShowInTabOptionBtn, TextareaAutoComplete, savedItemCountEl, indentati
throw ({ description: code.diagnostics[0].messageText, lineNumber: ts.getLineOfLocalPosition(code.diagnostics[0].file,code.diagnostics[0].start) }); throw ({ description: code.diagnostics[0].messageText, lineNumber: ts.getLineOfLocalPosition(code.diagnostics[0].file,code.diagnostics[0].start) });
} }
if (shouldPreventInfiniteLoops !== false) { if (shouldPreventInfiniteLoops !== false) {
code = utils.addInfiniteLoopProtection(ast); code = utils.addInfiniteLoopProtection(code.outputText);
} }
d.resolve(code); d.resolve(code);
} catch (e) { } catch (e) {

View File

@ -54,7 +54,7 @@
var varStr = 'var %d = Date.now();\n' var varStr = 'var %d = Date.now();\n'
var checkStr = '\nif (Date.now() - %d > 1000) { window.top.previewException(new Error("Infinite loop")); break;}\n' var checkStr = '\nif (Date.now() - %d > 1000) { window.top.previewException(new Error("Infinite loop")); break;}\n'
esprima.parse(code, { tolerant: true, range: true }, function (node) { esprima.parse(code, { tolerant: true, range: true, jsx: true }, function (node) {
switch (node.type) { switch (node.type) {
case 'DoWhileStatement': case 'DoWhileStatement':
case 'ForStatement': case 'ForStatement':