Fixed #33571 -- Fixed static serving views crash when If-Modified-Since is empty.
Regression in d6aff369ad
.
This commit is contained in:
parent
d90e34c61b
commit
71017a68a6
|
@ -129,12 +129,14 @@ def was_modified_since(header=None, mtime=0, size=0):
|
||||||
if header is None:
|
if header is None:
|
||||||
raise ValueError
|
raise ValueError
|
||||||
matches = re.match(r"^([^;]+)(; length=([0-9]+))?$", header, re.IGNORECASE)
|
matches = re.match(r"^([^;]+)(; length=([0-9]+))?$", header, re.IGNORECASE)
|
||||||
|
if matches is None:
|
||||||
|
raise ValueError
|
||||||
header_mtime = parse_http_date(matches[1])
|
header_mtime = parse_http_date(matches[1])
|
||||||
header_len = matches[3]
|
header_len = matches[3]
|
||||||
if header_len and int(header_len) != size:
|
if header_len and int(header_len) != size:
|
||||||
raise ValueError
|
raise ValueError
|
||||||
if int(mtime) > header_mtime:
|
if int(mtime) > header_mtime:
|
||||||
raise ValueError
|
raise ValueError
|
||||||
except (AttributeError, ValueError, OverflowError):
|
except (ValueError, OverflowError):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
|
@ -191,3 +191,6 @@ class StaticUtilsTests(unittest.TestCase):
|
||||||
mtime = 1343416141.107817
|
mtime = 1343416141.107817
|
||||||
header = http_date(mtime)
|
header = http_date(mtime)
|
||||||
self.assertFalse(was_modified_since(header, mtime))
|
self.assertFalse(was_modified_since(header, mtime))
|
||||||
|
|
||||||
|
def test_was_modified_since_empty_string(self):
|
||||||
|
self.assertTrue(was_modified_since(header="", mtime=1))
|
||||||
|
|
Loading…
Reference in New Issue