escape_sqlite() favors double quotes, closes #2795

This commit is contained in:
Simon Willison 2026-06-23 14:04:20 -07:00
commit 22ccd8a087
2 changed files with 24 additions and 11 deletions

View file

@ -410,12 +410,7 @@ def escape_css_string(s):
def escape_sqlite(s):
if _boring_keyword_re.match(s) and (s.lower() not in reserved_words):
return s
elif "]" in s:
# SQLite does not support escaping ] inside [bracket] quoting, so fall
# back to double-quote quoting (doubling any embedded ") - #2677
return '"{}"'.format(s.replace('"', '""'))
else:
return f"[{s}]"
return '"{}"'.format(s.replace('"', '""'))
def make_dockerfile(