Skip to content

Commit

Permalink
fix: add JSDoc again
Browse files Browse the repository at this point in the history
  • Loading branch information
jean-michelet committed Jan 27, 2024
1 parent 0b44071 commit 4408684
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/AstAnalyser.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ export class AstAnalyser {
}
}

/**
* @param {!string} source
* @param {object} options
* @param {boolean} [options.removeHTMLComments=false]
*/
prepareSource(source, options = {}) {
if (typeof source !== "string") {
throw new TypeError("source must be a string");
Expand All @@ -107,13 +112,17 @@ export class AstAnalyser {
* @example
* #!/usr/bin/env node
*/
const rawNoShebang = source.charAt(0) === "#" ?
const rawNoShebang = source.startsWith("#") ?
source.slice(source.indexOf("\n") + 1) : source;

return removeHTMLComments ?
this.#removeHTMLComment(rawNoShebang) : rawNoShebang;
}

/**
* @param {!string} str
* @returns {string}
*/
#removeHTMLComment(str) {
return str.replaceAll(/<!--[\s\S]*?(?:-->)/g, "");

Check failure

Code scanning / CodeQL

Polynomial regular expression used on uncontrolled data High

This
regular expression
that depends on
library input
may run slow on strings starting with '<!--' and with many repetitions of '<!--'.
This
regular expression
that depends on
library input
may run slow on strings starting with '<!--' and with many repetitions of '<!--'.

Check failure

Code scanning / CodeQL

Incomplete multi-character sanitization High

This string may still contain
<!--
, which may cause an HTML element injection vulnerability.
}
Expand Down

0 comments on commit 4408684

Please sign in to comment.