feat(files): block upload and show warning for legacy .ppt/.doc file formats
- Set file_list_status to 'blocked_legacy' when any selected file is .ppt or .doc, disabling the Upload button until the file is removed - Show a red banner at the top when upload is blocked - Add a per-file warning message row in the file table for all legacy/untrusted extensions (previously computed but never rendered — only a pink cell highlight) - Red styling for blocking extensions (.ppt/.doc), yellow for warn-only Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -215,6 +215,10 @@ async function process_file_list(file_list: FileList) {
|
|||||||
|
|
||||||
file_data['warning_message'] = warning_message;
|
file_data['warning_message'] = warning_message;
|
||||||
|
|
||||||
|
// .ppt and .doc must be converted before upload — block, don't just warn
|
||||||
|
file_data['block_upload'] =
|
||||||
|
guessed_extension === 'ppt' || guessed_extension === 'doc';
|
||||||
|
|
||||||
file_data['uploaded'] = null;
|
file_data['uploaded'] = null;
|
||||||
file_data['uploaded_bytes'] = null;
|
file_data['uploaded_bytes'] = null;
|
||||||
|
|
||||||
@@ -272,7 +276,8 @@ async function process_file_list(file_list: FileList) {
|
|||||||
// input_file_list_processed.push(file_data);
|
// input_file_list_processed.push(file_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
file_list_status = 'ready';
|
const has_blocked = processed_file_list.some((f) => f.block_upload);
|
||||||
|
file_list_status = has_blocked ? 'blocked_legacy' : 'ready';
|
||||||
console.log(processed_file_list);
|
console.log(processed_file_list);
|
||||||
|
|
||||||
// return JSON.parse(JSON.stringify(processed_file_list));
|
// return JSON.parse(JSON.stringify(processed_file_list));
|
||||||
@@ -361,6 +366,13 @@ run(() => {
|
|||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
{#if file_list_status == 'blocked_legacy'}
|
||||||
|
<div class="m-1 rounded-md border-2 border-red-500 bg-red-100 p-3 text-sm text-red-800 dark:bg-red-900/30 dark:text-red-200">
|
||||||
|
<strong>⚠ Upload blocked — legacy file format detected.</strong>
|
||||||
|
Please remove the flagged file(s) below and re-save in the modern format before uploading.
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
|
||||||
<!-- {#await processed_file_list} -->
|
<!-- {#await processed_file_list} -->
|
||||||
<!-- {:then} -->
|
<!-- {:then} -->
|
||||||
{#if use_selected_file_table && processed_file_list && processed_file_list.length}
|
{#if use_selected_file_table && processed_file_list && processed_file_list.length}
|
||||||
@@ -426,6 +438,19 @@ run(() => {
|
|||||||
})}
|
})}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
{#if file_list_item.warning_message}
|
||||||
|
<tr>
|
||||||
|
<td colspan="6"
|
||||||
|
class="text-left text-xs"
|
||||||
|
class:bg-red-100={file_list_item.block_upload}
|
||||||
|
class:text-red-800={file_list_item.block_upload}
|
||||||
|
class:bg-yellow-50={!file_list_item.block_upload}
|
||||||
|
class:text-yellow-900={!file_list_item.block_upload}>
|
||||||
|
<!-- eslint-disable-next-line svelte/no-at-html-tags -->
|
||||||
|
{@html file_list_item.warning_message}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{/if}
|
||||||
</tbody>
|
</tbody>
|
||||||
{/each}
|
{/each}
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
Reference in New Issue
Block a user