Skip to content
Myr

Fix extract_zipped_paths infinite loop when provided invalid unc path (#5851)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Thomas Lam · committed by GitHub · parent b227e3c · Browse files · 2 files+8 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+8 added−0 removed

  • tests:+4 added−0 removed
  • other:+4 added−0 removed

2 files+8 added−0 removed

modified:requests/utils.py+4 added
249 unmodified lines
250 # assume the rest of the path is the name of a member in the archive251 archive, member = os.path.split(path)252 while archive and not os.path.exists(archive):253 archive, prefix = os.path.split(archive)254 if not prefix:255 # If we don't check for an empty prefix after the split (in other words, archive remains unchanged after the split),256 # we _can_ end up in an infinite loop on a rare corner case affecting a small number of users257 break258 member = '/'.join([prefix, member])259260 if not zipfile.is_zipfile(archive):261 return path
756 unmodified lines
modified:tests/test_utils.py+4 added
283 unmodified lines
284 assert extracted_path != zipped_path285 assert os.path.exists(extracted_path)286 assert filecmp.cmp(extracted_path, __file__)287288 def test_invalid_unc_path(self):289 path = r"\\localhost\invalid\location"290 assert extract_zipped_paths(path) == path291292293class TestContentEncodingDetection:294295 def test_none(self):296 encodings = get_encodings_from_content('')
491 unmodified lines