锁定移动壳二进制导出校验顺序
移动壳配置检查覆盖图片导出 MIME 校验早于原生分享探测 移动壳配置检查覆盖音频导出 MIME 校验早于原生分享探测 移动壳文件导出顺序反查复用统一校验逻辑
This commit is contained in:
@@ -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 [
|
||||
|
||||
Reference in New Issue
Block a user