mirror of
https://github.com/makeplane/plane.git
synced 2026-09-01 19:48:42 +02:00
[INFRA-779] use str.translate instead of a char-by-char rebuild for tab/CR/LF stripping
Address /code-review cleanup finding, following the same fix applied to
the plane-ee port (INFRA-780): single-pass str.translate is shorter and
matches the terse style of the adjacent .replace("\\", "") line.
Also verified, and declining, the review's other finding on the EE port
(delegate to Django's url_has_allowed_host_and_scheme instead of
hand-rolling the "//" check): Django's own _url_has_allowed_host_and_scheme
does not strip tab/CR/LF before its startswith("///") check either, so it
would reintroduce the exact bypass this PR fixed, and validate_next_path
also does path-traversal/suspicious-pattern checks Django's helper doesn't
attempt at all.
Co-authored-by: Plane AI <noreply@plane.so>
This commit is contained in:
@@ -120,7 +120,7 @@ def validate_next_path(next_path: str) -> str:
|
||||
# scheme-free string here and a literal .startswith("//") below would
|
||||
# miss it too (the second character is a tab, not a slash). Strip them
|
||||
# here so every check downstream sees what the browser will.
|
||||
next_path = "".join(char for char in next_path if char not in "\t\r\n")
|
||||
next_path = next_path.translate(str.maketrans("", "", "\t\r\n"))
|
||||
|
||||
parsed_url = urlparse(next_path)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user