Merge branch 'feature/UpdateTornado' into dev

This commit is contained in:
JackDandy 2023-09-06 01:26:39 +01:00
commit 03988841a3
3 changed files with 27 additions and 5 deletions

View file

@ -2,6 +2,7 @@
* Update Beautiful Soup 4.11.1 (r642) to 4.12.2 * Update Beautiful Soup 4.11.1 (r642) to 4.12.2
* Update soupsieve 2.3.2.post1 (792d566) to 2.4.1 (2e66beb) * Update soupsieve 2.3.2.post1 (792d566) to 2.4.1 (2e66beb)
* Update Tornado Web Server 6.3.2 (e3aa6c5) to 6.3.3 (e4d6984)
* Fix regex that was not using py312 notation * Fix regex that was not using py312 notation
* Change sort backlog and manual segment search results episode number * Change sort backlog and manual segment search results episode number
* Change sort episodes when set to wanted on display show page * Change sort episodes when set to wanted on display show page

View file

@ -22,8 +22,8 @@
# is zero for an official release, positive for a development branch, # is zero for an official release, positive for a development branch,
# or negative for a release candidate or beta (after the base version # or negative for a release candidate or beta (after the base version
# number has been incremented) # number has been incremented)
version = "6.3.2" version = "6.3.3"
version_info = (6, 3, 2, 0) version_info = (6, 3, 3, 0)
import importlib import importlib
import typing import typing

View file

@ -442,7 +442,7 @@ class HTTP1Connection(httputil.HTTPConnection):
): ):
self._expected_content_remaining = 0 self._expected_content_remaining = 0
elif "Content-Length" in headers: elif "Content-Length" in headers:
self._expected_content_remaining = int(headers["Content-Length"]) self._expected_content_remaining = parse_int(headers["Content-Length"])
else: else:
self._expected_content_remaining = None self._expected_content_remaining = None
# TODO: headers are supposed to be of type str, but we still have some # TODO: headers are supposed to be of type str, but we still have some
@ -618,7 +618,7 @@ class HTTP1Connection(httputil.HTTPConnection):
headers["Content-Length"] = pieces[0] headers["Content-Length"] = pieces[0]
try: try:
content_length = int(headers["Content-Length"]) # type: Optional[int] content_length: Optional[int] = parse_int(headers["Content-Length"])
except ValueError: except ValueError:
# Handles non-integer Content-Length value. # Handles non-integer Content-Length value.
raise httputil.HTTPInputError( raise httputil.HTTPInputError(
@ -668,7 +668,10 @@ class HTTP1Connection(httputil.HTTPConnection):
total_size = 0 total_size = 0
while True: while True:
chunk_len_str = await self.stream.read_until(b"\r\n", max_bytes=64) chunk_len_str = await self.stream.read_until(b"\r\n", max_bytes=64)
chunk_len = int(chunk_len_str.strip(), 16) try:
chunk_len = parse_hex_int(native_str(chunk_len_str[:-2]))
except ValueError:
raise httputil.HTTPInputError("invalid chunk size")
if chunk_len == 0: if chunk_len == 0:
crlf = await self.stream.read_bytes(2) crlf = await self.stream.read_bytes(2)
if crlf != b"\r\n": if crlf != b"\r\n":
@ -846,3 +849,21 @@ class HTTP1ServerConnection(object):
await asyncio.sleep(0) await asyncio.sleep(0)
finally: finally:
delegate.on_close(self) delegate.on_close(self)
DIGITS = re.compile(r"[0-9]+")
HEXDIGITS = re.compile(r"[0-9a-fA-F]+")
def parse_int(s: str) -> int:
"""Parse a non-negative integer from a string."""
if DIGITS.fullmatch(s) is None:
raise ValueError("not an integer: %r" % s)
return int(s)
def parse_hex_int(s: str) -> int:
"""Parse a non-negative hexadecimal integer from a string."""
if HEXDIGITS.fullmatch(s) is None:
raise ValueError("not a hexadecimal integer: %r" % s)
return int(s, 16)