Skip to content

Commit 0e09cf3

Browse files
authored
Merge pull request #846 from enricoros/claude/issue-844-20251016-0857
fix: properly handle null and undefined in clipboard operations
2 parents 07916be + 5634aa0 commit 0e09cf3

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

src/common/attachment-drafts/useAttachmentDrafts.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,11 @@ export function useAttachmentDrafts(attachmentsStoreApi: AttachmentDraftsStoreAp
238238
for (const clipboardItem of clipboardItems) {
239239

240240
// https://github.com/enricoros/big-AGI/issues/286
241-
const textHtml = clipboardItem.types.includes('text/html') ? await clipboardItem.getType('text/html').then(blob => blob.text()) : '';
241+
const textHtml = clipboardItem.types.includes('text/html')
242+
? await clipboardItem.getType('text/html')
243+
.then(blob => blob?.text() ?? '')
244+
.catch(() => '')
245+
: '';
242246
const heuristicBypassImage = textHtml.startsWith('<table ');
243247

244248
if (ATTACHMENTS_DEBUG_INTAKE)
@@ -269,7 +273,11 @@ export function useAttachmentDrafts(attachmentsStoreApi: AttachmentDraftsStoreAp
269273
}
270274

271275
// get the Plain text
272-
const textPlain = clipboardItem.types.includes('text/plain') ? await clipboardItem.getType('text/plain').then(blob => blob.text()) : '';
276+
const textPlain = clipboardItem.types.includes('text/plain')
277+
? await clipboardItem.getType('text/plain')
278+
.then(blob => blob?.text() ?? '')
279+
.catch(() => '')
280+
: '';
273281

274282
// attach as URL
275283
if (textPlain && enableLoadURLsOnPaste) {

0 commit comments

Comments
 (0)