Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix build step parsing that includes newlines #344

Merged
merged 2 commits into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading