Files
Bingxi Zhao (Frank) 6c024857b7 release: v1.4.1 — security & stability patch
Security: lock down the TutorBot tool sandbox (shell exec is opt-in, all
filesystem/shell access confined to the bot workspace) and isolate per-user
resources, closing #518, #517, #516, #515, #514 and #506 (first hardened in
#507).

Bug fixes: chat input disabled after the first turn (#520), KB embedding
failure on long documents (#521 / #509), profile creation under Docker
(#512 / #513), Qwen reasoning models failing native tool calling (#527 / #528),
the GPT-5 init-wizard token parameter (#508), and oversized session-event
truncation (#524).

Features: HTTP/SSE API for multi-turn chat with a specific TutorBot (#511),
multimodal image fallback for vision-capable providers without a capability
entry, safe ZIP knowledge upload, and a /settings/network page with model
fetching (community PRs #522 and #523 reimplemented locally).

Also bumps __version__ to 1.4.1, adds the v1.4.1 release notes, updates the
README Releases section, and ships the Astro + Starlight docs site under site/.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-27 23:16:00 +08:00

56 lines
1.6 KiB
Python

from __future__ import annotations
import re
from typing import Any, Iterable
from urllib.parse import urlparse
_ORIGIN_SEPARATORS = re.compile(r"[,;\n]+")
def _raw_origin_items(value: Any) -> Iterable[str]:
if value is None:
return []
if isinstance(value, (list, tuple, set)):
items: list[str] = []
for item in value:
items.extend(_raw_origin_items(item))
return items
return _ORIGIN_SEPARATORS.split(str(value))
def normalize_origin(value: Any) -> str:
"""Normalize a browser Origin value for CORS allowlists.
Operators often paste values as ``host:port`` or separate multiple origins
with semicolons. Browsers always send an Origin as ``scheme://host[:port]``.
This helper makes common deployment input tolerant while keeping the output
as exact origins for Starlette's CORSMiddleware.
"""
origin = str(value or "").strip().rstrip("/")
if not origin:
return ""
if origin in {"*", "null"}:
return origin
if "://" not in origin:
origin = f"http://{origin}"
try:
parsed = urlparse(origin)
except ValueError:
return origin
if parsed.scheme in {"http", "https"} and parsed.netloc:
return f"{parsed.scheme}://{parsed.netloc}".rstrip("/")
return origin
def normalize_origins(value: Any) -> list[str]:
origins: list[str] = []
seen: set[str] = set()
for raw in _raw_origin_items(value):
origin = normalize_origin(raw)
if origin and origin not in seen:
origins.append(origin)
seen.add(origin)
return origins