Skip to content

Commit f2cf560

Browse files
committed
[FIX] core: inline _WHATWG_C0_CONTROL_OR_SPACE
This is a private variable of the stdlib, it was added in Python 3.12 (python/cpython#102508) and only backported to 3.11.4 (cpython/python#104575) and 3.10.12 (cpython/python#104592) so is not necessarily available in versions of 3.10 and 3.11 clients might be running. So embed the content into the file directly to avoid depending on the stdlib. Not to mention the concept of C0 is not exactly novel or mutable. Also inline it in its sole use, there's no reason to have multiple string literals and a runtime concatenation. Fixes odoo#230990 X-original-commit: 0374281
1 parent e83f58a commit f2cf560

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

odoo/tools/urls.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import re
22
import urllib.parse
3-
from urllib.parse import _WHATWG_C0_CONTROL_OR_SPACE
43

54
__all__ = ['urljoin']
65

@@ -63,7 +62,7 @@ def urljoin(base: str, extra: str) -> str:
6362
if e_path:
6463
# prevent urljoin("/", "\\example.com/") to resolve as absolute to "//example.com/" in a browser redirect
6564
# https://github.com/mozilla-firefox/firefox/blob/5e81b64f4ed88b610eb332e103744d68ee8b6c0d/netwerk/base/nsStandardURL.cpp#L2386-L2388
66-
e_path = e_path.lstrip('/\\' + _WHATWG_C0_CONTROL_OR_SPACE)
65+
e_path = e_path.lstrip('/\\\x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f ')
6766
path = f'{path}/{e_path}'
6867

6968
# normalize: foo//bar -> foo/bar

0 commit comments

Comments
 (0)