Skip to content

Commit

Permalink
fix: build step parsing that includes newlines (#344) (#345)
Browse files Browse the repository at this point in the history
Co-authored-by: Michal Szelag <michal.szelag@sonos.com>
  • Loading branch information
kronenthaler and michalszelagsonos authored Apr 10, 2024
1 parent 4cdea53 commit ecc86b7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pbxproj/PBXGenericObject.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down
1 change: 1 addition & 0 deletions tests/TestPBXGenericObject.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"'
Expand Down

0 comments on commit ecc86b7

Please sign in to comment.