fix(partition-table): reject non-Latin-1 characters in partition names
This commit is contained in:
parent
402fade928
commit
d01c81b48f
|
|
@ -1,5 +1,6 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, computed } from 'vue';
|
import { ref, computed } from 'vue';
|
||||||
|
import { ElMessage } from 'element-plus';
|
||||||
import {
|
import {
|
||||||
type PartitionTable, type PartitionEntry,
|
type PartitionTable, type PartitionEntry,
|
||||||
PartitionType, PartitionFlags,
|
PartitionType, PartitionFlags,
|
||||||
|
|
@ -20,8 +21,6 @@ const props = defineProps<{
|
||||||
// ── Core state ─────────────────────────────────────────────────────
|
// ── Core state ─────────────────────────────────────────────────────
|
||||||
|
|
||||||
const table = ref<PartitionTable>({ entries: [], md5Valid: false });
|
const table = ref<PartitionTable>({ entries: [], md5Valid: false });
|
||||||
const statusMessage = ref('');
|
|
||||||
const statusType = ref<'success' | 'error' | 'info'>('info');
|
|
||||||
|
|
||||||
// Add dialog
|
// Add dialog
|
||||||
const showAddDialog = ref(false);
|
const showAddDialog = ref(false);
|
||||||
|
|
@ -51,9 +50,7 @@ function getSubtypeOptionsForType(type: PartitionType) {
|
||||||
// ── Helpers ────────────────────────────────────────────────────────
|
// ── Helpers ────────────────────────────────────────────────────────
|
||||||
|
|
||||||
function showStatus(msg: string, type: 'success' | 'error' | 'info' = 'info') {
|
function showStatus(msg: string, type: 'success' | 'error' | 'info' = 'info') {
|
||||||
statusMessage.value = msg;
|
ElMessage({ message: msg, type, duration: 4000, showClose: true });
|
||||||
statusType.value = type;
|
|
||||||
setTimeout(() => { statusMessage.value = ''; }, 4000);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatHex(val: number): string {
|
function formatHex(val: number): string {
|
||||||
|
|
@ -262,18 +259,6 @@ function handleExportCsv() {
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<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 ── -->
|
<!-- ── Toolbar ── -->
|
||||||
<div class="flex flex-wrap items-center gap-2 mb-3">
|
<div class="flex flex-wrap items-center gap-2 mb-3">
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import type { PartitionEntry, PartitionTable } from './types';
|
import type { PartitionEntry, PartitionTable } from './types';
|
||||||
|
|
||||||
export interface PartitionValidationError {
|
export interface PartitionValidationError {
|
||||||
type: 'overlap' | 'alignment' | 'duplicate_name';
|
type: 'overlap' | 'alignment' | 'duplicate_name' | 'invalid_encoding';
|
||||||
message: string;
|
message: string;
|
||||||
entryA?: PartitionEntry;
|
entryA?: PartitionEntry;
|
||||||
entryB?: PartitionEntry;
|
entryB?: PartitionEntry;
|
||||||
|
|
@ -13,6 +13,17 @@ export function validateTable(table: PartitionTable): PartitionValidationError[]
|
||||||
const errors: PartitionValidationError[] = [];
|
const errors: PartitionValidationError[] = [];
|
||||||
const entries = table.entries;
|
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
|
// Duplicate name detection
|
||||||
const names = new Map<string, PartitionEntry>();
|
const names = new Map<string, PartitionEntry>();
|
||||||
for (const entry of entries) {
|
for (const entry of entries) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue