From 1504f55cdf6c9d972af5a11a5c40fc4a7df95df3 Mon Sep 17 00:00:00 2001 From: Barry Downes Date: Sun, 6 Aug 2023 15:32:19 +1000 Subject: [PATCH] Fix: Updated strip_c_comments function didn't work. In regex, "." is literal inside a character class. --- comfy/comments.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/comfy/comments.py b/comfy/comments.py index d6deb076c..8c37a8c4c 100644 --- a/comfy/comments.py +++ b/comfy/comments.py @@ -4,7 +4,8 @@ import re def strip_c_comments(text, strict=True): # Processes the text and strips out any C-style block "/* ... */" or line "// ..." comments found. # from old dynamicPrompts.js: return str.replace(/\/\*[\s\S]*?\*\/|\/\/.*/g,''); - return re.sub(r'/\*[.\n]*?(?:\*/|$)|//.*', '', text) + text = re.sub(r'/\*.*?(?:\*/|$)|//[^\n]*', '', text, flags=re.DOTALL) + return text def strip_hash_comments(text, strict=True): # Processes the text and strips out any hash "# ... " comments found.