Skip to content

Commit b898fc0

Browse files
committed
fix: gravatar profile image
1 parent eb5c95e commit b898fc0

3 files changed

Lines changed: 17 additions & 1 deletion

File tree

backend/open_webui/utils/validate.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
'/static/favicon.png',
77
)
88

9+
# External URL prefixes that are explicitly trusted for profile images
10+
_ALLOWED_URL_PREFIXES = (
11+
'https://www.gravatar.com/avatar/',
12+
)
13+
914

1015
def validate_profile_image_url(url: str) -> str:
1116
"""
@@ -15,6 +20,7 @@ def validate_profile_image_url(url: str) -> str:
1520
- Empty string (falls back to default avatar)
1621
- data:image/* URIs (base64-encoded uploads from the frontend)
1722
- Known static asset paths (/user.png, /static/favicon.png)
23+
- Trusted external URLs (e.g. Gravatar)
1824
1925
Returns the url unchanged if valid, raises ValueError otherwise.
2026
"""
@@ -33,4 +39,7 @@ def validate_profile_image_url(url: str) -> str:
3339
if url in _ALLOWED_STATIC_PATHS:
3440
return url
3541

42+
if any(url.startswith(prefix) for prefix in _ALLOWED_URL_PREFIXES):
43+
return url
44+
3645
raise ValueError('Invalid profile image URL: only data URIs and default avatars are allowed.')

src/lib/apis/auths/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,9 @@ export const updateUserProfile = async (token: string, profile: object) => {
413413
.catch((err) => {
414414
console.error(err);
415415
error = err.detail;
416+
if (Array.isArray(error)) {
417+
error = error.map((e: { msg?: string }) => e.msg).join("; ");
418+
}
416419
return null;
417420
});
418421

src/lib/apis/utils/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,14 @@ export const getGravatarUrl = async (token: string, email: string) => {
1616
})
1717
.catch((err) => {
1818
console.error(err);
19-
error = err;
19+
error = err.detail ?? err;
2020
return null;
2121
});
2222

23+
if (error) {
24+
throw error;
25+
}
26+
2327
return res;
2428
};
2529

0 commit comments

Comments
 (0)