Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/components/UserMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,14 @@ export const UserMenu: React.FC = () => {
};

const handleImageProxyUrlChange = (value: string) => {
setImageProxyUrl(value);
if (typeof window !== 'undefined') {
localStorage.setItem('imageProxyUrl', value);
try {
const url = new URL(value); // Validate URL format
setImageProxyUrl(url.toString());
if (typeof window !== 'undefined') {
localStorage.setItem('imageProxyUrl', url.toString());
}
} catch (e) {
console.error('Invalid image proxy URL:', value);
}
};

Expand Down
8 changes: 7 additions & 1 deletion src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,13 @@ export function processImageUrl(originalUrl: string): string {
const proxyUrl = getImageProxyUrl();
if (!proxyUrl) return originalUrl;

return `${proxyUrl}${encodeURIComponent(originalUrl)}`;
try {
const validatedProxyUrl = new URL(proxyUrl); // Validate proxy URL
return `${validatedProxyUrl.toString()}${encodeURIComponent(originalUrl)}`;
} catch (e) {
console.error('Invalid proxy URL:', proxyUrl);
return originalUrl;
}
}

/**
Expand Down