mirror of
https://github.com/open-webui/open-webui
synced 2025-06-26 18:26:48 +00:00
Introduce canvasPixelTest() intended to validate canvas functionality
Browsers and plugins that spoof canvas data produce corrupt images. In attempt to mitigate: * Add canvasPixelTest() to test a single pixel and test the RGB values * Test canvasPixelTest() inside generateInitialsImage() and use default `/user.png` if failure detected * Call canvasPixelTest() directly within settings to avoid setting an invalid image * Use toast.error() with 10 second autoClose
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
import { updateUserProfile } from '$lib/apis/auths';
|
||||
|
||||
import UpdatePassword from './Account/UpdatePassword.svelte';
|
||||
import { generateInitialsImage } from '$lib/utils';
|
||||
import { generateInitialsImage, canvasPixelTest } from '$lib/utils';
|
||||
import { copyToClipboard } from '$lib/utils';
|
||||
|
||||
const i18n = getContext('i18n');
|
||||
@@ -148,7 +148,13 @@
|
||||
<button
|
||||
class=" text-xs text-gray-600"
|
||||
on:click={async () => {
|
||||
profileImageUrl = generateInitialsImage(name);
|
||||
if (canvasPixelTest()) {
|
||||
profileImageUrl = generateInitialsImage(name);
|
||||
} else {
|
||||
toast.error("Canvas pixel test failed, fingerprint evasion likely. Disable fingerprint evasion and try again!", {
|
||||
autoClose: 1000 * 10,
|
||||
});
|
||||
}
|
||||
}}>{$i18n.t('Use Gravatar')}</button
|
||||
>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user