Skip to content

Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.

fixed code styling issue

Saurav Panda2552caeca4dc
diff --git a/browser_use/filesystem/file_system.py b/browser_use/filesystem/file_system.py
index 4ca6b5049..a3be9a8f8 100644
--- a/browser_use/filesystem/file_system.py
+++ b/browser_use/filesystem/file_system.py
@@ -186,7 +186,7 @@ class CsvFile(BaseFile):
trailing/leading blank lines, and double-escaped JSON output
(literal backslash-n and backslash-quote instead of real newlines/quotes).
"""
- stripped = raw.strip()
+ stripped = raw.strip('\n\r')
if not stripped:
return raw
@@ -220,7 +220,7 @@ class CsvFile(BaseFile):
def append_file_content(self, content: str) -> None:
"""Normalize the appended CSV rows and merge with existing content."""
normalized_new = self._normalize_csv(content)
- if not normalized_new.strip():
+ if not normalized_new.strip('\n\r'):
return
existing = self.content
if existing and not existing.endswith('\n'):
diff --git a/tests/ci/infrastructure/test_filesystem.py b/tests/ci/infrastructure/test_filesystem.py
index 4472fb779..779a5f89d 100644
--- a/tests/ci/infrastructure/test_filesystem.py
+++ b/tests/ci/infrastructure/test_filesystem.py
@@ -1414,3 +1414,9 @@ class TestCsvNormalization:
csv_file.write_file_content('path,desc\n/tmp/a\\nb,test file')
# Real newlines present → no unescaping, literal \n stays in the field
assert csv_file.content == 'path,desc\n/tmp/a\\nb,test file'
+
+ def test_normalize_preserves_leading_trailing_spaces_in_fields(self):
+ """Leading/trailing spaces in field values must not be stripped."""
+ csv_file = CsvFile(name='test')
+ csv_file.write_file_content(' name , age \nAlice, 30 ')
+ assert csv_file.content == ' name , age \nAlice, 30 '