From 05548f9cd391ffae5e9027a17aab2d61c8d2ce20 Mon Sep 17 00:00:00 2001 From: Michal Szelag Date: Tue, 9 Apr 2024 06:15:38 -0400 Subject: [PATCH 1/2] Update PBXGenericObject.py --- pbxproj/PBXGenericObject.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pbxproj/PBXGenericObject.py b/pbxproj/PBXGenericObject.py index 658f4c6..0ad00d4 100644 --- a/pbxproj/PBXGenericObject.py +++ b/pbxproj/PBXGenericObject.py @@ -10,7 +10,8 @@ class PBXGenericObject(object): Generic class that creates internal attributes to match the structure of the tree used to create the element. Also, prints itself using the openstep format. Extensions might be required to insert comments on right places. """ - _VALID_KEY_REGEX = re.compile(r'^[a-zA-Z0-9\\._/]*$') + # use negative look-ahead to avoid matching the newline character in multiline strings + _VALID_KEY_REGEX = re.compile(r'^[a-zA-Z0-9\\._/]*(?!\n)$') _ESCAPE_REPLACEMENTS = [ ('\\', '\\\\'), ('\n', '\\n'), From 5e091f56729ba3a55c7cbb3e418aeeb1986bb707 Mon Sep 17 00:00:00 2001 From: Michal Szelag Date: Tue, 9 Apr 2024 06:40:57 -0400 Subject: [PATCH 2/2] Updated unit tests --- tests/TestPBXGenericObject.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/TestPBXGenericObject.py b/tests/TestPBXGenericObject.py index e2cfddb..ab0c3ed 100644 --- a/tests/TestPBXGenericObject.py +++ b/tests/TestPBXGenericObject.py @@ -27,6 +27,7 @@ def testParseKey(self): def testEscapeItem(self): assert PBXGenericObject._escape("/bin/sh") == "/bin/sh" + assert PBXGenericObject._escape("/bin/sh\n") == '"/bin/sh\\n"' assert PBXGenericObject._escape("abcdefghijklmnopqrstuvwyz0123456789") == \ "abcdefghijklmnopqrstuvwyz0123456789" assert PBXGenericObject._escape("some spaces") == '"some spaces"'