script-lab icon indicating copy to clipboard operation
script-lab copied to clipboard

Error when using a string with the content "</script>"

Open Rickyp opened this issue 7 years ago • 3 comments

Host: Excel online, using Chrome There is a parsing/compiling error somewhere that happens when the user code contains a string with the content "". For example:

// User code $("#run").click(() => tryCatch(run));

async function run() { console.log(""); }

/** Default helper for invoking an action and handling errors. */ async function tryCatch(callback) { try { await callback(); } catch (error) { OfficeHelpers.UI.notify(error); OfficeHelpers.Utilities.log(error); } }

EXPECTED: It console logs ""

ACTUAL: image

Rickyp avatar Jan 30 '19 17:01 Rickyp

Good catch, super-interesting. I thought we were escaping the string inside the script, but looks like we're not. I can take this one.

Zlatkovsky avatar Jan 30 '19 17:01 Zlatkovsky

BTW, if you're blocked, I'm pretty sure that if you switch to Script Lab 2017 (see instructions), this should work for you.

Zlatkovsky avatar Jan 30 '19 17:01 Zlatkovsky

Hmmm how could we do this? What if the user wanted to print out ""

nico-bellante avatar Jan 30 '19 18:01 nico-bellante