This repository was archived by the owner on May 2, 2026. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -186,19 +186,19 @@ def shell_safe(text: Optional[str]) -> str:
186186 """
187187 Escapes a string for safe inclusion in a Python script string literal.
188188 This is used when generating Python cache scripts with embedded text content.
189-
190- For Python triple-quoted strings , we need to:
189+
190+ For Python string literals , we need to:
191191 - Escape backslashes first (so existing backslashes don't interfere)
192- - Escape triple quotes (to not break the string literal )
193- - Remove or replace problematic characters
192+ - Escape double quotes (to not break double-quoted string literals )
193+ - Escape single quotes (to not break single-quoted string literals)
194194 """
195195 if not text :
196196 return ""
197197 # Escape backslashes first
198198 result = text .replace ("\\ " , "\\ \\ " )
199- # Escape triple quotes ( both types) for Python triple-quoted string literals
200- result = result .replace ('""" ' , r'\ "\"\"' )
201- result = result .replace ("''' " , r"\'\' \'" )
199+ # Escape both quote types for safe inclusion in any string literal
200+ result = result .replace ('"' , r"\"" )
201+ result = result .replace ("'" , r"\'" )
202202 return result
203203
204204
You can’t perform that action at this time.
0 commit comments