diff --git a/deluge/config.py b/deluge/config.py index 5550182e7..1bf433683 100644 --- a/deluge/config.py +++ b/deluge/config.py @@ -91,8 +91,13 @@ def find_json_objects(s): if start < 0: return [] + quoted = False for index, c in enumerate(s[offset:]): - if c == '{': + if c == '"': + quoted = not quoted + elif quoted: + continue + elif c == '{': opens += 1 elif c == '}': opens -= 1 diff --git a/deluge/tests/test_config.py b/deluge/tests/test_config.py index b7c009087..eca84a9e3 100644 --- a/deluge/tests/test_config.py +++ b/deluge/tests/test_config.py @@ -168,3 +168,20 @@ class ConfigTestCase(unittest.TestCase): objects = find_json_objects(s) self.assertEqual(len(objects), 2) + + def test_find_json_objects_curly_brace(self): + """Test with string containing curly brace""" + s = """{ + "file": 1, + "format": 1 +}{ + "ssl": true, + "enabled": false, + "port": 8115 + "password": "abc{def" +}\n""" + + from deluge.config import find_json_objects + + objects = find_json_objects(s) + self.assertEqual(len(objects), 2)