mirror of
https://github.com/chinchang/web-maker.git
synced 2025-07-14 10:36:19 +02:00
fix loop protection for ts and es6 code
This commit is contained in:
@ -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) {
|
||||||
|
@ -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':
|
||||||
|
Reference in New Issue
Block a user