Merge pull request #4 from rockenman1234/docs

add mark fixes
This commit is contained in:
Alex Jenkins 2026-04-13 19:36:43 -04:00 committed by GitHub
commit dda89107e2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 9 additions and 1 deletions

BIN
.coverage

Binary file not shown.

View file

@ -98,11 +98,14 @@ def normalize_language(value: Optional[str]) -> str:
return "en"
# Returns a mutable object - caller must not mutate!
@lru_cache(maxsize=32)
def get_language_pack(language: str) -> Dict[str, str]:
"""Load the language pack for `language` from package resources."""
lang = normalize_language(language)
if lang not in SUPPORTED_LANGUAGES:
lang = "en"
try:
with importlib_resources.open_text(

View file

@ -40,6 +40,12 @@ class I18nPackEndpoint:
return web.HTTPUnauthorized()
lang = request.match_info.get("lang") or "en"
# This is a path traversal defense, and is a critical sec defense.
# Do not remove!
if "/" in lang or ".." in lang:
return web.HTTPBadRequest(reason="Invalid language code")
pack = get_language_pack(lang)
return web.json_response(pack)

View file

@ -1 +0,0 @@
__version__ = "2.2.999"