From 26ea2856c7a90aec892b98d94a9b7a3e18539045 Mon Sep 17 00:00:00 2001 From: Yang Jun Date: Sun, 3 May 2026 21:36:09 +0800 Subject: [PATCH] fix: strip html newline tags (#892) * docs: add @talboren as financial contributor * fix(strip_html): match tags that span newlines inside angle brackets Co-authored-by: Cursor --------- Co-authored-by: Cursor --- src/filters/html.ts | 2 +- test/integration/filters/html.spec.ts | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/filters/html.ts b/src/filters/html.ts index 3121857e3..0dd5f77d3 100644 --- a/src/filters/html.ts +++ b/src/filters/html.ts @@ -45,5 +45,5 @@ export function newline_to_br (this: FilterImpl, v: string) { export function strip_html (this: FilterImpl, v: string) { const str = stringify(v) this.context.memoryLimit.use(str.length) - return str.replace(/||<.*?>|/g, '') + return str.replace(/||<[\s\S]*?>|/g, '') } diff --git a/test/integration/filters/html.spec.ts b/test/integration/filters/html.spec.ts index fce809d3a..c4551dad4 100644 --- a/test/integration/filters/html.spec.ts +++ b/test/integration/filters/html.spec.ts @@ -77,5 +77,10 @@ describe('filters/html', function () { it('should strip until empty', function () { return test('{{"

< p >

" | strip_html }}', '') }) + it('should strip generic tags spanning ASCII newlines inside the tag', function () { + expect(liquid.parseAndRenderSync('{{"" | strip_html}}')).toBe('') + expect(liquid.parseAndRenderSync('{{"" | strip_html}}')).toBe('') + expect(liquid.parseAndRenderSync('{{"" | strip_html}}')).toBe('') + }) }) })