mirror of
https://github.com/SableClient/Sable.git
synced 2026-11-26 03:46:25 -08:00
Fix embed toLowerCase crash (#1047)
<!-- Please read https://github.com/SableClient/Sable/blob/dev/CONTRIBUTING.md before submitting your pull request --> ### Description <!-- Please include a summary of the change. Please also include relevant motivation and context. List any dependencies that are required for this change. --> Fixes #1046 caused by embed images since they don't have bodies and therefore couldn't be lowercased :( #### Type of change - [x] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] This change requires a documentation update ### Checklist: - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings ### AI disclosure: - [ ] Partially AI assisted (clarify which code was AI assisted and briefly explain what it does). - [ ] Fully AI generated (explain what all the generated code does in moderate detail). <!-- Write any explanation required here, but do not generate the explanation using AI!! You must prove you understand what the code in this PR does. -->
This commit is contained in:
2 files changed
+13
-8
No files matched your search
@@ -0,0 +1,5 @@
|
||||
---
|
||||
default: patch
|
||||
---
|
||||
|
||||
Fix crash with some embed links.
|
||||
@@ -83,7 +83,7 @@ type RenderImageProps = {
|
||||
tabIndex: number;
|
||||
};
|
||||
export type ImageContentProps = {
|
||||
body: string;
|
||||
body?: string;
|
||||
mimeType?: string;
|
||||
url: string;
|
||||
info?: IImageInfo;
|
||||
@@ -141,9 +141,9 @@ export const ImageContent = as<'div', ImageContentProps>(
|
||||
info?.mimetype === 'image/gif' ||
|
||||
info?.mimetype === 'image/apng' ||
|
||||
info?.mimetype === 'image/webp' ||
|
||||
body.toLowerCase().endsWith('.gif') ||
|
||||
body.toLowerCase().endsWith('.apng') ||
|
||||
body.toLowerCase().endsWith('.webp') ||
|
||||
(body ?? '').toLowerCase().endsWith('.gif') ||
|
||||
(body ?? '').toLowerCase().endsWith('.apng') ||
|
||||
(body ?? '').toLowerCase().endsWith('.webp') ||
|
||||
url.toLowerCase().endsWith('.gif') ||
|
||||
url.toLowerCase().endsWith('.apng') ||
|
||||
url.toLowerCase().endsWith('.webp');
|
||||
@@ -269,7 +269,7 @@ export const ImageContent = as<'div', ImageContentProps>(
|
||||
>
|
||||
{renderViewer({
|
||||
src: viewerFullSrc ?? srcState.data,
|
||||
alt: body,
|
||||
alt: body ?? '',
|
||||
requestClose: () => setViewer(false),
|
||||
info: info,
|
||||
})}
|
||||
@@ -315,8 +315,8 @@ export const ImageContent = as<'div', ImageContentProps>(
|
||||
style={{ width: '100%' }}
|
||||
>
|
||||
{renderImage({
|
||||
alt: body,
|
||||
title: body,
|
||||
alt: body ?? '',
|
||||
title: body ?? '',
|
||||
src: srcState.data,
|
||||
onLoad: handleLoad,
|
||||
onError: handleError,
|
||||
@@ -437,7 +437,7 @@ export const ImageContent = as<'div', ImageContentProps>(
|
||||
gifs: [
|
||||
...favoritedContent.gifs,
|
||||
{
|
||||
title: body,
|
||||
title: body ?? '',
|
||||
url: url,
|
||||
width: imageW,
|
||||
height: imageH,
|
||||
|
||||
Reference in new issue
Block a user