Skip to content

Conversation

@yiwen101
Copy link
Contributor

@yiwen101 yiwen101 commented Apr 7, 2023

could generate the searchData json file which is needed for performing search at frontEnd;

could generate the searchData json file which is needed for performing search at frontEnd;
@yiwen101 yiwen101 requested a review from samuelfangjw April 7, 2023 18:43
if (matches.length) {
for (const match of matches) {
const matchStr = match[0].toString();
const newStr = matchStr.replace(/_/g, "\\_");

Check failure

Code scanning / CodeQL

Incomplete string escaping or encoding

This does not escape backslash characters in the input.
// Text tags: tag that is parsed as text
"#text": (node, obj) => {
// ignore the section/subsection tags at the end of chapter/section files
if (!node.nodeValue.match(/&(\w|\.|\d)+;/)) {

Check failure

Code scanning / CodeQL

Inefficient regular expression

This part of the regular expression may cause exponential backtracking on strings starting with '&' and containing many repetitions of '0'.

META: (node, obj) => {
let s = node.firstChild.nodeValue;
s = s.replace(/-/g, "-").replace(/ /g, "\\ ");

Check failure

Code scanning / CodeQL

Replacement of a substring with itself

This replaces '-' with itself.

META: (node, obj) => {
let s = node.firstChild.nodeValue;
s = s.replace(/-/g, "-").replace(/ /g, "\\ ");

Check failure

Code scanning / CodeQL

Incomplete string escaping or encoding

This does not escape backslash characters in the input.
Copy link
Member

@martin-henz martin-henz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Follows the style of the XML processing.

@martin-henz martin-henz merged commit 57b25d7 into source-academy:master Apr 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants