From dc788283adaedcb15586cd347bf02ae8f8f37f01 Mon Sep 17 00:00:00 2001 From: Huang Xin Date: Thu, 9 Apr 2026 12:54:20 +0800 Subject: [PATCH] security: fix for code scanning alert no. 11: Incomplete multi-character sanitization (#3804) * security: fix for code scanning alert no. 11: Incomplete multi-character sanitization Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> * fix: use dotAll flag to match multi-line HTML comments Add the 's' flag to the comment-stripping regex so '.' matches newlines, ensuring comments spanning multiple lines are also removed. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- apps/readest-app/src/utils/txt.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/apps/readest-app/src/utils/txt.ts b/apps/readest-app/src/utils/txt.ts index d75f8f9a..037e9310 100644 --- a/apps/readest-app/src/utils/txt.ts +++ b/apps/readest-app/src/utils/txt.ts @@ -547,7 +547,13 @@ export class TxtToEpubConverter { ): number { const { language } = metadata; const { fallbackParagraphsPerChapter } = option; - const trimmedSegment = segment.replace(//g, '').trim(); + let sanitizedSegment = segment; + let previousSegment: string; + do { + previousSegment = sanitizedSegment; + sanitizedSegment = sanitizedSegment.replace(//gs, ''); + } while (sanitizedSegment !== previousSegment); + const trimmedSegment = sanitizedSegment.trim(); if (!trimmedSegment) return 0; const chapterRegexps = this.createChapterRegexps(language);