From 0afe87d7fb72063a04b3a010aece6efed283a062 Mon Sep 17 00:00:00 2001 From: Tony Brix Date: Thu, 7 Nov 2024 10:23:40 -0700 Subject: [PATCH] fix: fix del with escaped tilde (#3517) * fix: fix del with escaped tilde * use rules to check for unescaped tilde * add tests with spaces --- src/rules.ts | 2 +- test/specs/new/escape_within_del.html | 6 ++++++ test/specs/new/escape_within_del.md | 11 +++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 test/specs/new/escape_within_del.html create mode 100644 test/specs/new/escape_within_del.md diff --git a/src/rules.ts b/src/rules.ts index 0dd0f84770..d132f8706b 100644 --- a/src/rules.ts +++ b/src/rules.ts @@ -301,7 +301,7 @@ const inlineGfm: Record = { .replace('email', /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/) .getRegex(), _backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/, - del: /^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/, + del: /^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/, text: /^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\\

+

~\~

+

~

+

~\~~

+

~~ ~

+

~ ~~

diff --git a/test/specs/new/escape_within_del.md b/test/specs/new/escape_within_del.md new file mode 100644 index 0000000000..0421e75dad --- /dev/null +++ b/test/specs/new/escape_within_del.md @@ -0,0 +1,11 @@ +~\\~ + +~\\\~ + +~\~~ + +~\\~~ + +~\~ ~ + +~ \~~