Skip to content

Commit

Permalink
fix: add sanitization of strings for json insert
Browse files Browse the repository at this point in the history
  • Loading branch information
faradox committed Mar 1, 2024
1 parent a084146 commit 65b5cf5
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/nendo/library/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,11 @@ def convert(obj):
if isinstance(obj, (NestedMutableDict, dict)):
return {k: convert(v) for k, v in obj.items()}
if isinstance(obj, str):
# Remove non-ASCII characters from the string
return obj.encode("ascii", "ignore").decode("ascii").replace("\u0000", "")
# samitize the string
sanitized_str = obj.encode("ascii", "ignore").decode("ascii")
sanitized_str = sanitized_str.replace("'", "\\'")
sanitized_str = sanitized_str.replace("\u0000", "")
return sanitized_str
return obj


Expand Down

0 comments on commit 65b5cf5

Please sign in to comment.