Skip to content

Commit 4a40799

Browse files
fix: build step parsing that includes newlines (#344)
1 parent 4cdea53 commit 4a40799

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

pbxproj/PBXGenericObject.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ class PBXGenericObject(object):
1010
Generic class that creates internal attributes to match the structure of the tree used to create the element.
1111
Also, prints itself using the openstep format. Extensions might be required to insert comments on right places.
1212
"""
13-
_VALID_KEY_REGEX = re.compile(r'^[a-zA-Z0-9\\._/]*$')
13+
# use negative look-ahead to avoid matching the newline character in multiline strings
14+
_VALID_KEY_REGEX = re.compile(r'^[a-zA-Z0-9\\._/]*(?!\n)$')
1415
_ESCAPE_REPLACEMENTS = [
1516
('\\', '\\\\'),
1617
('\n', '\\n'),

tests/TestPBXGenericObject.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ def testParseKey(self):
2727

2828
def testEscapeItem(self):
2929
assert PBXGenericObject._escape("/bin/sh") == "/bin/sh"
30+
assert PBXGenericObject._escape("/bin/sh\n") == '"/bin/sh\\n"'
3031
assert PBXGenericObject._escape("abcdefghijklmnopqrstuvwyz0123456789") == \
3132
"abcdefghijklmnopqrstuvwyz0123456789"
3233
assert PBXGenericObject._escape("some spaces") == '"some spaces"'

0 commit comments

Comments
 (0)