Skip to content

Commit

Permalink
fix: add escaping for backslash \
Browse files Browse the repository at this point in the history
  • Loading branch information
kronenthaler committed Jan 16, 2017
1 parent 90ce0b6 commit 4e8796c
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
7 changes: 4 additions & 3 deletions pbxproj/PBXGenericObject.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,11 @@ def _generate_id(cls):
@classmethod
def _escape(cls, item):
if item.__len__() == 0 or re.match(cls._VALID_KEY_REGEX, item).group(0) != item:
escaped = item.replace(u'\n', u'\\n')\
escaped = item.replace(u'\\', u'\\\\')\
.replace(u'\n', u'\\n')\
.replace(u'\"', u'\\"')\
.replace(u'\0', u'\\0')\
.replace(u'\'',u'\\\'')\
.replace(u'\t',u'\\\t')
.replace(u'\'', u'\\\'')\
.replace(u'\t', u'\\\t')
return u'"{0}"'.format(escaped)
return item
2 changes: 1 addition & 1 deletion pbxproj/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@
from pbxproj.XcodeProject import XcodeProject
from pbxproj.pbxsections import *

__version__ = '2.0.1'
__version__ = '2.0.2'
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def run_tests(self):
]
},
url="http://github.com/kronenthaler/mod-pbxproj",
version='2.0.1',
version='2.0.2',
license='MIT License',
install_requires=['openstep_parser', 'docopt'],
packages=find_packages(exclude=['tests']),
Expand Down
1 change: 1 addition & 0 deletions tests/TestPBXGenericObject.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def testEscapeItem(self):
self.assertEqual(PBXGenericObject._escape("a.valid_id."), "a.valid_id.")
self.assertEqual(PBXGenericObject._escape("a-invalid-id"), '"a-invalid-id"')
self.assertEqual(PBXGenericObject._escape("<group>"), '"<group>"')
self.assertEqual(PBXGenericObject._escape("script \\ continuation"), '"script \\\\ continuation"')

def testPrintObject(self):
obj = {"a": "varA", "b": [1, 2, 3], "c": {"c1": "FDDF6A571C68E5B100D7A645"}}
Expand Down

0 comments on commit 4e8796c

Please sign in to comment.