redbot 2.4.0__tar.gz → 2.4.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {redbot-2.4.0/redbot.egg-info → redbot-2.4.2}/PKG-INFO +1 -1
- {redbot-2.4.0 → redbot-2.4.2}/redbot/__init__.py +1 -1
- {redbot-2.4.0 → redbot-2.4.2}/redbot/resource/__init__.py +1 -1
- {redbot-2.4.0 → redbot-2.4.2}/redbot/resource/link_parse.py +6 -0
- {redbot-2.4.0 → redbot-2.4.2}/redbot/webui/handlers/run_test.py +34 -6
- {redbot-2.4.0 → redbot-2.4.2/redbot.egg-info}/PKG-INFO +1 -1
- {redbot-2.4.0 → redbot-2.4.2}/LICENSE.md +0 -0
- {redbot-2.4.0 → redbot-2.4.2}/MANIFEST.in +0 -0
- {redbot-2.4.0 → redbot-2.4.2}/README.md +0 -0
- {redbot-2.4.0 → redbot-2.4.2}/pyproject.toml +0 -0
- {redbot-2.4.0 → redbot-2.4.2}/redbot/assets/__init__.py +0 -0
- {redbot-2.4.0 → redbot-2.4.2}/redbot/assets/icons/__init__.py +0 -0
- {redbot-2.4.0 → redbot-2.4.2}/redbot/assets/icons/check-circle.svg +0 -0
- {redbot-2.4.0 → redbot-2.4.2}/redbot/assets/icons/exclamation-circle.svg +0 -0
- {redbot-2.4.0 → redbot-2.4.2}/redbot/assets/icons/info-circle.svg +0 -0
- {redbot-2.4.0 → redbot-2.4.2}/redbot/assets/icons/question-circle.svg +0 -0
- {redbot-2.4.0 → redbot-2.4.2}/redbot/assets/icons/times-circle.svg +0 -0
- {redbot-2.4.0 → redbot-2.4.2}/redbot/assets/logo/__init__.py +0 -0
- {redbot-2.4.0 → redbot-2.4.2}/redbot/assets/logo/apple-touch-icon-144x144.png +0 -0
- {redbot-2.4.0 → redbot-2.4.2}/redbot/assets/logo/apple-touch-icon-152x152.png +0 -0
- {redbot-2.4.0 → redbot-2.4.2}/redbot/assets/logo/favicon-16x16.png +0 -0
- {redbot-2.4.0 → redbot-2.4.2}/redbot/assets/logo/favicon-32x32.png +0 -0
- {redbot-2.4.0 → redbot-2.4.2}/redbot/assets/logo/favicon.ico +0 -0
- {redbot-2.4.0 → redbot-2.4.2}/redbot/assets/logo/mstile-144x144.png +0 -0
- {redbot-2.4.0 → redbot-2.4.2}/redbot/assets/logo/redbot-sq.png +0 -0
- {redbot-2.4.0 → redbot-2.4.2}/redbot/assets/prettify.js +0 -0
- {redbot-2.4.0 → redbot-2.4.2}/redbot/assets/prettify.js.map +0 -0
- {redbot-2.4.0 → redbot-2.4.2}/redbot/assets/red_style.css +0 -0
- {redbot-2.4.0 → redbot-2.4.2}/redbot/assets/red_style.css.map +0 -0
- {redbot-2.4.0 → redbot-2.4.2}/redbot/assets/script.js +0 -0
- {redbot-2.4.0 → redbot-2.4.2}/redbot/assets/script.js.map +0 -0
- {redbot-2.4.0 → redbot-2.4.2}/redbot/assets/style.css +0 -0
- {redbot-2.4.0 → redbot-2.4.2}/redbot/cli.py +0 -0
- {redbot-2.4.0 → redbot-2.4.2}/redbot/daemon.py +0 -0
- {redbot-2.4.0 → redbot-2.4.2}/redbot/formatter/__init__.py +0 -0
- {redbot-2.4.0 → redbot-2.4.2}/redbot/formatter/har.py +0 -0
- {redbot-2.4.0 → redbot-2.4.2}/redbot/formatter/html.py +0 -0
- {redbot-2.4.0 → redbot-2.4.2}/redbot/formatter/html_base.py +0 -0
- {redbot-2.4.0 → redbot-2.4.2}/redbot/formatter/null_links.py +0 -0
- {redbot-2.4.0 → redbot-2.4.2}/redbot/formatter/templates/__init__.py +0 -0
- {redbot-2.4.0 → redbot-2.4.2}/redbot/formatter/templates/footer.html +0 -0
- {redbot-2.4.0 → redbot-2.4.2}/redbot/formatter/templates/response_finish.html +0 -0
- {redbot-2.4.0 → redbot-2.4.2}/redbot/formatter/templates/response_multi_finish.html +0 -0
- {redbot-2.4.0 → redbot-2.4.2}/redbot/formatter/templates/response_start.html +0 -0
- {redbot-2.4.0 → redbot-2.4.2}/redbot/formatter/text.py +0 -0
- {redbot-2.4.0 → redbot-2.4.2}/redbot/i18n.py +0 -0
- {redbot-2.4.0 → redbot-2.4.2}/redbot/note.py +0 -0
- {redbot-2.4.0 → redbot-2.4.2}/redbot/resource/active_check/__init__.py +0 -0
- {redbot-2.4.0 → redbot-2.4.2}/redbot/resource/active_check/base.py +0 -0
- {redbot-2.4.0 → redbot-2.4.2}/redbot/resource/active_check/conneg.py +0 -0
- {redbot-2.4.0 → redbot-2.4.2}/redbot/resource/active_check/etag_validate.py +0 -0
- {redbot-2.4.0 → redbot-2.4.2}/redbot/resource/active_check/lm_validate.py +0 -0
- {redbot-2.4.0 → redbot-2.4.2}/redbot/resource/active_check/range.py +0 -0
- {redbot-2.4.0 → redbot-2.4.2}/redbot/resource/fetch.py +0 -0
- {redbot-2.4.0 → redbot-2.4.2}/redbot/translations/__init__.py +0 -0
- {redbot-2.4.0 → redbot-2.4.2}/redbot/translations/es/LC_MESSAGES/messages.mo +0 -0
- {redbot-2.4.0 → redbot-2.4.2}/redbot/translations/es/LC_MESSAGES/messages.po +0 -0
- {redbot-2.4.0 → redbot-2.4.2}/redbot/translations/extra_strings.py +0 -0
- {redbot-2.4.0 → redbot-2.4.2}/redbot/translations/fr/LC_MESSAGES/messages.mo +0 -0
- {redbot-2.4.0 → redbot-2.4.2}/redbot/translations/fr/LC_MESSAGES/messages.po +0 -0
- {redbot-2.4.0 → redbot-2.4.2}/redbot/translations/ja/LC_MESSAGES/messages.mo +0 -0
- {redbot-2.4.0 → redbot-2.4.2}/redbot/translations/ja/LC_MESSAGES/messages.po +0 -0
- {redbot-2.4.0 → redbot-2.4.2}/redbot/translations/messages.pot +0 -0
- {redbot-2.4.0 → redbot-2.4.2}/redbot/translations/zh/LC_MESSAGES/messages.mo +0 -0
- {redbot-2.4.0 → redbot-2.4.2}/redbot/translations/zh/LC_MESSAGES/messages.po +0 -0
- {redbot-2.4.0 → redbot-2.4.2}/redbot/type.py +0 -0
- {redbot-2.4.0 → redbot-2.4.2}/redbot/utils.py +0 -0
- {redbot-2.4.0 → redbot-2.4.2}/redbot/webui/__init__.py +0 -0
- {redbot-2.4.0 → redbot-2.4.2}/redbot/webui/captcha.py +0 -0
- {redbot-2.4.0 → redbot-2.4.2}/redbot/webui/handlers/__init__.py +0 -0
- {redbot-2.4.0 → redbot-2.4.2}/redbot/webui/handlers/base.py +0 -0
- {redbot-2.4.0 → redbot-2.4.2}/redbot/webui/handlers/client_error.py +0 -0
- {redbot-2.4.0 → redbot-2.4.2}/redbot/webui/handlers/error.py +0 -0
- {redbot-2.4.0 → redbot-2.4.2}/redbot/webui/handlers/save.py +0 -0
- {redbot-2.4.0 → redbot-2.4.2}/redbot/webui/handlers/show.py +0 -0
- {redbot-2.4.0 → redbot-2.4.2}/redbot/webui/links.py +0 -0
- {redbot-2.4.0 → redbot-2.4.2}/redbot/webui/ratelimit.py +0 -0
- {redbot-2.4.0 → redbot-2.4.2}/redbot/webui/saved_tests.py +0 -0
- {redbot-2.4.0 → redbot-2.4.2}/redbot.egg-info/SOURCES.txt +0 -0
- {redbot-2.4.0 → redbot-2.4.2}/redbot.egg-info/dependency_links.txt +0 -0
- {redbot-2.4.0 → redbot-2.4.2}/redbot.egg-info/entry_points.txt +0 -0
- {redbot-2.4.0 → redbot-2.4.2}/redbot.egg-info/requires.txt +0 -0
- {redbot-2.4.0 → redbot-2.4.2}/redbot.egg-info/top_level.txt +0 -0
- {redbot-2.4.0 → redbot-2.4.2}/setup.cfg +0 -0
|
@@ -56,7 +56,7 @@ class HttpResource(RedFetcher):
|
|
|
56
56
|
self.linked: List[Tuple[HttpResource, str]] = [] # linked HttpResources
|
|
57
57
|
self._link_parser = link_parse.HTMLLinkParser(self.response, [self.process_link])
|
|
58
58
|
if self.descend or config.getboolean("content_links", False):
|
|
59
|
-
self.
|
|
59
|
+
self.response.decoded.processors.append(self._link_parser.feed_bytes)
|
|
60
60
|
|
|
61
61
|
def run_active_checks(self) -> None:
|
|
62
62
|
"""
|
|
@@ -13,6 +13,7 @@ from httplint.message import HttpMessageLinter
|
|
|
13
13
|
from httplint.syntax import rfc9110
|
|
14
14
|
|
|
15
15
|
DEFAULT_ENCODING = "utf-8"
|
|
16
|
+
MAX_FEED_BYTES = 2 * 1024 * 1024
|
|
16
17
|
|
|
17
18
|
|
|
18
19
|
class HTMLLinkParser(HTMLParser):
|
|
@@ -57,6 +58,7 @@ class HTMLLinkParser(HTMLParser):
|
|
|
57
58
|
self.errors = 0
|
|
58
59
|
self.last_err_pos: int = 0
|
|
59
60
|
self.ok = True
|
|
61
|
+
self.bytes_fed = 0
|
|
60
62
|
HTMLParser.__init__(self)
|
|
61
63
|
|
|
62
64
|
def __getstate__(self) -> Dict[str, Any]:
|
|
@@ -65,6 +67,10 @@ class HTMLLinkParser(HTMLParser):
|
|
|
65
67
|
def feed_bytes(self, bchunk: bytes) -> None:
|
|
66
68
|
"Feed a given chunk of bytes to the parser"
|
|
67
69
|
if self.ok:
|
|
70
|
+
self.bytes_fed += len(bchunk)
|
|
71
|
+
if self.bytes_fed > MAX_FEED_BYTES:
|
|
72
|
+
self.ok = False
|
|
73
|
+
return
|
|
68
74
|
encoding = self.message.character_encoding or DEFAULT_ENCODING
|
|
69
75
|
decoded = bchunk.decode(encoding, "ignore")
|
|
70
76
|
self.feed(decoded)
|
|
@@ -10,12 +10,13 @@ from urllib.parse import urlencode, urlsplit
|
|
|
10
10
|
|
|
11
11
|
import thor
|
|
12
12
|
import thor.events
|
|
13
|
+
from httplint.util import iri_to_uri
|
|
13
14
|
from markupsafe import escape
|
|
14
15
|
|
|
15
16
|
from redbot.formatter import find_formatter
|
|
16
17
|
from redbot.resource import HttpResource
|
|
17
18
|
from redbot.resource.active_check import active_checks
|
|
18
|
-
from redbot.type import RawHeaderListType, RedWebUiProtocol
|
|
19
|
+
from redbot.type import RawHeaderListType, RedWebUiProtocol
|
|
19
20
|
from redbot.utils import e_url
|
|
20
21
|
from redbot.webui.captcha import CaptchaHandler
|
|
21
22
|
from redbot.webui.handlers.base import RequestHandler
|
|
@@ -25,6 +26,29 @@ from redbot.webui.saved_tests import init_save_file, save_test
|
|
|
25
26
|
if TYPE_CHECKING:
|
|
26
27
|
from redbot.formatter import Formatter
|
|
27
28
|
|
|
29
|
+
_BAD_HEADER_NAME_CHARS = set('()<>@,;:\\"/[]?={} \t\r\n')
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def _validate_req_hdrs(raw: List[str]) -> Tuple[List[Tuple[str, str]], Optional[str]]:
|
|
33
|
+
"""Parse and validate user-supplied req_hdr entries.
|
|
34
|
+
|
|
35
|
+
Returns (headers, error). When error is not None, headers is meaningless
|
|
36
|
+
and the test should not run.
|
|
37
|
+
"""
|
|
38
|
+
headers: List[Tuple[str, str]] = []
|
|
39
|
+
for entry in raw:
|
|
40
|
+
if ":" not in entry:
|
|
41
|
+
return [], f"Request header {entry!r} is missing a colon."
|
|
42
|
+
name, value = entry.split(":", 1)
|
|
43
|
+
if not name:
|
|
44
|
+
return [], "Request header field name is empty."
|
|
45
|
+
if any(c in _BAD_HEADER_NAME_CHARS or ord(c) < 33 or ord(c) > 126 for c in name):
|
|
46
|
+
return [], f"Request header field name {name!r} contains invalid characters."
|
|
47
|
+
if "\r" in value or "\n" in value:
|
|
48
|
+
return [], f"Request header {name!r} value contains CR or LF."
|
|
49
|
+
headers.append((name, value))
|
|
50
|
+
return headers, None
|
|
51
|
+
|
|
28
52
|
|
|
29
53
|
class RunTestHandler(RequestHandler):
|
|
30
54
|
"""
|
|
@@ -59,11 +83,15 @@ class RunTestHandler(RequestHandler):
|
|
|
59
83
|
"""
|
|
60
84
|
test_id = init_save_file(ui)
|
|
61
85
|
test_uri = ui.query_string.get("uri", [""])[0]
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
86
|
+
try:
|
|
87
|
+
iri_to_uri(test_uri).encode("ascii")
|
|
88
|
+
except (ValueError, UnicodeError):
|
|
89
|
+
ui.error_response(b"400", b"Bad Request", "Request URI is malformed.")
|
|
90
|
+
return
|
|
91
|
+
test_req_hdrs, hdr_error = _validate_req_hdrs(ui.query_string.get("req_hdr", []))
|
|
92
|
+
if hdr_error:
|
|
93
|
+
ui.error_response(b"400", b"Bad Request", hdr_error)
|
|
94
|
+
return
|
|
67
95
|
descend = "descend" in ui.query_string
|
|
68
96
|
|
|
69
97
|
top_resource = HttpResource(ui.config, descend=descend)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|