diff options
author | Jo-Philipp Wich <jo@mein.io> | 2020-05-29 09:56:06 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2020-05-29 09:57:29 +0200 |
commit | 6be8f8dbaee90a8a7e8bc87350f21793b9aed35c (patch) | |
tree | 75f5765471d20cbdffc540fdcf7b11b6602ca602 /modules | |
parent | 80580d7238169926dd8c2f6a10cf241ed6f136a5 (diff) |
luci-base: luci.js: properly skip comments when finding require tokens
Fixes: #4020, #4022, #4111
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'modules')
-rw-r--r-- | modules/luci-base/htdocs/luci-static/resources/luci.js | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/modules/luci-base/htdocs/luci-static/resources/luci.js b/modules/luci-base/htdocs/luci-static/resources/luci.js index 4b6894c08..83c2807d7 100644 --- a/modules/luci-base/htdocs/luci-static/resources/luci.js +++ b/modules/luci-base/htdocs/luci-static/resources/luci.js @@ -2462,12 +2462,19 @@ args = ''; /* find require statements in source */ - for (var i = 0, off = -1, quote = -1, esc = false; i < source.length; i++) { + for (var i = 0, off = -1, prev = -1, quote = -1, comment = -1, esc = false; i < source.length; i++) { var chr = source.charCodeAt(i); if (esc) { esc = false; } + else if (comment != -1) { + if ((comment == 47 && chr == 10) || (comment == 42 && prev == 42 && chr == 47)) + comment = -1; + } + else if ((chr == 42 || chr == 47) && prev == 47) { + comment = chr; + } else if (chr == 92) { esc = true; } @@ -2491,6 +2498,8 @@ off = i + 1; quote = chr; } + + prev = chr; } /* load dependencies and instantiate class */ |