From 8a0285382ce64855f4f91aae65efec6d2b7b0b5a Mon Sep 17 00:00:00 2001 From: kdletters Date: Sat, 20 Jun 2026 15:10:24 +0800 Subject: [PATCH] =?UTF-8?q?=E9=94=81=E5=AE=9A=E7=A7=BB=E5=8A=A8=E5=A3=B3?= =?UTF-8?q?=E4=BA=8C=E8=BF=9B=E5=88=B6=E5=AF=BC=E5=87=BA=E6=A0=A1=E9=AA=8C?= =?UTF-8?q?=E9=A1=BA=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 移动壳配置检查覆盖图片导出 MIME 校验早于原生分享探测 移动壳配置检查覆盖音频导出 MIME 校验早于原生分享探测 移动壳文件导出顺序反查复用统一校验逻辑 --- apps/mobile-shell/scripts/check-config.mjs | 45 +++++++++++++++------- 1 file changed, 32 insertions(+), 13 deletions(-) diff --git a/apps/mobile-shell/scripts/check-config.mjs b/apps/mobile-shell/scripts/check-config.mjs index a4accea7d..a1bf7bc51 100644 --- a/apps/mobile-shell/scripts/check-config.mjs +++ b/apps/mobile-shell/scripts/check-config.mjs @@ -2104,19 +2104,38 @@ if ( ) { throw new Error('mobile shell image export must reject empty and oversized bytes'); } -const exportTextFileBody = extractFunctionBody(filesSource, 'exportTextFile'); -const exportTextMimeValidationIndex = exportTextFileBody.indexOf( - 'HOST_BRIDGE_TEXT_MIME_TYPE_SET.has(mimeType as HostBridgeTextMimeType)', -); -const exportTextSharingAvailabilityIndex = exportTextFileBody.indexOf( - 'await assertMobileFileSharingAvailable()', -); -if ( - exportTextMimeValidationIndex < 0 || - exportTextSharingAvailabilityIndex < 0 || - exportTextMimeValidationIndex > exportTextSharingAvailabilityIndex -) { - throw new Error('mobile shell text export must validate MIME before native sharing checks'); + +for (const [functionName, mimeCheckSnippet, label] of [ + [ + 'exportTextFile', + 'HOST_BRIDGE_TEXT_MIME_TYPE_SET.has(mimeType as HostBridgeTextMimeType)', + 'text', + ], + [ + 'exportImageFile', + 'HOST_BRIDGE_IMAGE_MIME_TYPE_SET.has(mimeType as HostBridgeImageMimeType)', + 'image', + ], + [ + 'exportAudioFile', + 'HOST_BRIDGE_AUDIO_MIME_TYPE_SET.has(mimeType as HostBridgeAudioMimeType)', + 'audio', + ], +]) { + const functionBody = extractFunctionBody(filesSource, functionName); + const mimeValidationIndex = functionBody.indexOf(mimeCheckSnippet); + const sharingAvailabilityIndex = functionBody.indexOf( + 'await assertMobileFileSharingAvailable()', + ); + if ( + mimeValidationIndex < 0 || + sharingAvailabilityIndex < 0 || + mimeValidationIndex > sharingAvailabilityIndex + ) { + throw new Error( + `mobile shell ${label} export must validate MIME before native sharing checks`, + ); + } } for (const [wrapperName, fileCall] of [