diff --git a/backend/chainlit/server.py b/backend/chainlit/server.py index 64f48490b1..a980fae605 100644 --- a/backend/chainlit/server.py +++ b/backend/chainlit/server.py @@ -961,7 +961,7 @@ async def get_logo(theme: Optional[Theme] = Query(Theme.light)): @router.get("/avatars/{avatar_id:str}") async def get_avatar(avatar_id: str): """Get the avatar for the user based on the avatar_id.""" - if not re.match(r"^[a-zA-Z0-9_ -]+$", avatar_id): + if not re.match(r"^[a-zA-Z0-9_-]+$", avatar_id): raise HTTPException(status_code=400, detail="Invalid avatar_id") if avatar_id == "default": diff --git a/backend/tests/test_server.py b/backend/tests/test_server.py index 91b152030f..6e98bca782 100644 --- a/backend/tests/test_server.py +++ b/backend/tests/test_server.py @@ -174,24 +174,6 @@ def test_get_avatar_custom(test_client: TestClient, monkeypatch: pytest.MonkeyPa os.remove(custom_avatar_path) -def test_get_avatar_with_spaces( - test_client: TestClient, monkeypatch: pytest.MonkeyPatch -): - """Test with custom avatar.""" - custom_avatar_path = os.path.join(APP_ROOT, "public", "avatars", "my_assistant.png") - os.makedirs(os.path.dirname(custom_avatar_path), exist_ok=True) - with open(custom_avatar_path, "wb") as f: - f.write(b"fake image data") - - response = test_client.get("/avatars/My Assistant") - assert response.status_code == 200 - assert response.headers["content-type"].startswith("image/") - assert response.content == b"fake image data" - - # Clean up - os.remove(custom_avatar_path) - - def test_get_avatar_non_existent_favicon( test_client: TestClient, monkeypatch: pytest.MonkeyPatch ):