mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-07-17 01:32:37 +02:00
zipinfo fix for paths with spaces
This commit is contained in:
@ -99,4 +99,4 @@ Returns:
|
|||||||
### Parser Information
|
### Parser Information
|
||||||
Compatibility: linux, darwin
|
Compatibility: linux, darwin
|
||||||
|
|
||||||
Version 1.1 by Matt J (https://github.com/listuser)
|
Version 1.2 by Matt J (https://github.com/listuser)
|
||||||
|
@ -77,7 +77,7 @@ import jc.parsers.universal
|
|||||||
|
|
||||||
class info():
|
class info():
|
||||||
"""Provides parser metadata (version, author, etc.)"""
|
"""Provides parser metadata (version, author, etc.)"""
|
||||||
version = '1.1'
|
version = '1.2'
|
||||||
description = '`zipinfo` command parser'
|
description = '`zipinfo` command parser'
|
||||||
author = 'Matt J'
|
author = 'Matt J'
|
||||||
author_email = 'https://github.com/listuser'
|
author_email = 'https://github.com/listuser'
|
||||||
@ -170,7 +170,8 @@ def parse(data, raw=False, quiet=False):
|
|||||||
# 1st line
|
# 1st line
|
||||||
# Archive: log4j-core-2.16.0.jar
|
# Archive: log4j-core-2.16.0.jar
|
||||||
line = archive_item.pop(0)
|
line = archive_item.pop(0)
|
||||||
_, archive = line.split()
|
# remove prefix but don't split on spaces for files/paths with spaces
|
||||||
|
archive = line.replace('Archive: ', '', 1)
|
||||||
|
|
||||||
# 2nd line
|
# 2nd line
|
||||||
# Zip file size: 1789565 bytes, number of entries: 1218
|
# Zip file size: 1789565 bytes, number of entries: 1218
|
||||||
|
1
tests/fixtures/rhel-8/zipinfo-space-in-name.json
vendored
Normal file
1
tests/fixtures/rhel-8/zipinfo-space-in-name.json
vendored
Normal file
File diff suppressed because one or more lines are too long
1221
tests/fixtures/rhel-8/zipinfo-space-in-name.out
vendored
Normal file
1221
tests/fixtures/rhel-8/zipinfo-space-in-name.out
vendored
Normal file
File diff suppressed because it is too large
Load Diff
@ -15,6 +15,9 @@ class MyTests(unittest.TestCase):
|
|||||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/osx-10.14.6/zipinfo-multi.out'), 'r', encoding='utf-8') as f:
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/osx-10.14.6/zipinfo-multi.out'), 'r', encoding='utf-8') as f:
|
||||||
osx_10_14_6_zipinfo_multi = f.read()
|
osx_10_14_6_zipinfo_multi = f.read()
|
||||||
|
|
||||||
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/rhel-8/zipinfo-space-in-name.out'), 'r', encoding='utf-8') as f:
|
||||||
|
rhel_8_zipinfo_space_in_name = f.read()
|
||||||
|
|
||||||
# output
|
# output
|
||||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/rhel-8/zipinfo.json'), 'r', encoding='utf-8') as f:
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/rhel-8/zipinfo.json'), 'r', encoding='utf-8') as f:
|
||||||
rhel_8_zipinfo_json = json.loads(f.read())
|
rhel_8_zipinfo_json = json.loads(f.read())
|
||||||
@ -22,6 +25,9 @@ class MyTests(unittest.TestCase):
|
|||||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/osx-10.14.6/zipinfo-multi.json'), 'r', encoding='utf-8') as f:
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/osx-10.14.6/zipinfo-multi.json'), 'r', encoding='utf-8') as f:
|
||||||
osx_10_14_6_zipinfo_multi_json = json.loads(f.read())
|
osx_10_14_6_zipinfo_multi_json = json.loads(f.read())
|
||||||
|
|
||||||
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/rhel-8/zipinfo-space-in-name.json'), 'r', encoding='utf-8') as f:
|
||||||
|
rhel_8_zipinfo_space_in_name_json = json.loads(f.read())
|
||||||
|
|
||||||
|
|
||||||
def test_zipinfo_nodata(self):
|
def test_zipinfo_nodata(self):
|
||||||
"""
|
"""
|
||||||
@ -41,6 +47,12 @@ class MyTests(unittest.TestCase):
|
|||||||
"""
|
"""
|
||||||
self.assertEqual(jc.parsers.zipinfo.parse(self.osx_10_14_6_zipinfo_multi, quiet=True), self.osx_10_14_6_zipinfo_multi_json)
|
self.assertEqual(jc.parsers.zipinfo.parse(self.osx_10_14_6_zipinfo_multi, quiet=True), self.osx_10_14_6_zipinfo_multi_json)
|
||||||
|
|
||||||
|
def test_zipinfo_rhel_8_space_in_name(self):
|
||||||
|
"""
|
||||||
|
Test 'zipinfo' on Red Hat 8 with spaces in the file path
|
||||||
|
"""
|
||||||
|
self.assertEqual(jc.parsers.zipinfo.parse(self.rhel_8_zipinfo_space_in_name, quiet=True), self.rhel_8_zipinfo_space_in_name_json)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
Reference in New Issue
Block a user