fix(partition-table): reject non-Latin-1 characters in partition names

This commit is contained in:
kerms 2026-03-12 12:10:06 +01:00
parent 402fade928
commit d01c81b48f
Signed by: kerms
GPG Key ID: 5432C10DDCF8DAD5
2 changed files with 14 additions and 18 deletions

View File

@ -1,5 +1,6 @@
<script setup lang="ts">
import { ref, computed } from 'vue';
import { ElMessage } from 'element-plus';
import {
type PartitionTable, type PartitionEntry,
PartitionType, PartitionFlags,
@ -20,8 +21,6 @@ const props = defineProps<{
// Core state
const table = ref<PartitionTable>({ entries: [], md5Valid: false });
const statusMessage = ref('');
const statusType = ref<'success' | 'error' | 'info'>('info');
// Add dialog
const showAddDialog = ref(false);
@ -51,9 +50,7 @@ function getSubtypeOptionsForType(type: PartitionType) {
// Helpers
function showStatus(msg: string, type: 'success' | 'error' | 'info' = 'info') {
statusMessage.value = msg;
statusType.value = type;
setTimeout(() => { statusMessage.value = ''; }, 4000);
ElMessage({ message: msg, type, duration: 4000, showClose: true });
}
function formatHex(val: number): string {
@ -262,18 +259,6 @@ function handleExportCsv() {
<template>
<div>
<!-- Status message -->
<transition name="el-fade-in">
<el-alert
v-if="statusMessage"
:title="statusMessage"
:type="statusType"
show-icon
closable
class="mb-3"
@close="statusMessage = ''"
/>
</transition>
<!-- Toolbar -->
<div class="flex flex-wrap items-center gap-2 mb-3">

View File

@ -1,7 +1,7 @@
import type { PartitionEntry, PartitionTable } from './types';
export interface PartitionValidationError {
type: 'overlap' | 'alignment' | 'duplicate_name';
type: 'overlap' | 'alignment' | 'duplicate_name' | 'invalid_encoding';
message: string;
entryA?: PartitionEntry;
entryB?: PartitionEntry;
@ -13,6 +13,17 @@ export function validateTable(table: PartitionTable): PartitionValidationError[]
const errors: PartitionValidationError[] = [];
const entries = table.entries;
// Encoding validation — partition names are stored as null-terminated Latin-1 byte strings
for (const entry of entries) {
if ([...entry.name].some(c => c.charCodeAt(0) > 0xFF)) {
errors.push({
type: 'invalid_encoding',
message: `Partition name "${entry.name}" contains non-Latin-1 characters (binary format only supports 8-bit characters)`,
entryA: entry,
});
}
}
// Duplicate name detection
const names = new Map<string, PartitionEntry>();
for (const entry of entries) {