diff --git a/test/test_util.py b/test/test_util.py index e09b52e40..91447b8b5 100644 --- a/test/test_util.py +++ b/test/test_util.py @@ -499,6 +499,9 @@ def test_is_weaviate_client_too_old(current_version: str, latest_version: str, t ('\\\\"', '\\\\\\"'), ('\\\\"', '\\\\\\"'), ('\\\\\\"', '\\\\\\"'), + ("foo\nbar", "foo bar"), + ("foo\r\nbar", "foo bar"), + ("foo\rbar", "foo bar"), ], ) def test_sanitize_str(in_str: str, out_str: str) -> None: diff --git a/weaviate/util.py b/weaviate/util.py index be61fe389..dc7ed2d49 100644 --- a/weaviate/util.py +++ b/weaviate/util.py @@ -497,7 +497,9 @@ def is_weaviate_domain(url: str) -> bool: def strip_newlines(s: str) -> str: - return s.replace("\n", " ") + # GraphQL treats CR as a line terminator inside string literals just like LF, + # so a CRLF value must collapse to one space instead of leaving a bare CR. + return s.replace("\r\n", "\n").replace("\r", "\n").replace("\n", " ") def _sanitize_str(value: str) -> str: