From 145511620c2483b7d4511107098580b70b933ce9 Mon Sep 17 00:00:00 2001 From: andy Date: Sun, 19 Jul 2026 14:20:06 +0700 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DV4=E6=9D=A5=E6=BA=90=E9=99=84?= =?UTF-8?q?=E4=BB=B6URL=E5=B1=95=E7=A4=BA=E8=84=B1=E6=95=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ReservationV4SourceMessageCard.vue | 16 +++++++-- client/src/tests/reservationV4Views.spec.ts | 33 ++++++++++++++++++- .../backend-to-frontend-notes.md | 3 +- ...002-v4-order-task-card-domain-model-cp2.md | 3 ++ .../security-access-control-boundary.md | 4 +-- 5 files changed, 53 insertions(+), 6 deletions(-) diff --git a/client/src/components/reservation/ReservationV4SourceMessageCard.vue b/client/src/components/reservation/ReservationV4SourceMessageCard.vue index 9c2bc4e..bb44d7c 100644 --- a/client/src/components/reservation/ReservationV4SourceMessageCard.vue +++ b/client/src/components/reservation/ReservationV4SourceMessageCard.vue @@ -175,8 +175,8 @@ function normalizeAttachments(value: unknown): AttachmentSummary[] { function toAttachmentSummary(value: unknown, index: number): AttachmentSummary { const record = readRecord(value) const name = record - ? readFirstString(record, ['name', 'file_name', 'filename', 'display_name', 'title']) ?? t('conversation.unnamedAttachment') - : String(value) + ? safeAttachmentName(readFirstString(record, ['name', 'file_name', 'filename', 'display_name', 'title'])) + : safeAttachmentName(String(value)) const type = record ? readFirstString(record, ['content_type', 'mime_type', 'media_type', 'file_type']) : null const size = record ? readNumber(record, 'size_bytes') ?? readNumber(record, 'size') : null return { @@ -249,6 +249,18 @@ function formatFileSize(size: number | null): string { } return `${(size / 1024 / 1024).toFixed(1)} MB` } + +function safeAttachmentName(value: string | null): string { + const trimmedValue = value?.trim() + if (!trimmedValue || isUnsafeAttachmentText(trimmedValue)) { + return t('conversation.unnamedAttachment') + } + return trimmedValue +} + +function isUnsafeAttachmentText(value: string): boolean { + return /^(https?:\/\/|oss:\/\/|s3:\/\/)/i.test(value.trim()) +}