multiple inconsistencies fixed (AI)

This commit is contained in:
2025-12-07 20:12:48 +01:00
parent 95367b4d14
commit d38b4c7813
8 changed files with 283 additions and 50 deletions

View File

@@ -22,8 +22,8 @@ export class BaseFilesystem {
// Helper function to format labels with offset information
const formatLabel = (label) => {
// Match patterns like "(Boot-Offset 0x00)", "(MFT-Header-Offset 0x14)", "(Offset 0x00)" and wrap offset info
const offsetPattern = /(\((Boot-Offset|MFT-Header-Offset|Offset) [^)]+\))/g;
// Match patterns like "(Boot-Offset 0x00)", "(MFT-Header-Offset 0x14)", "(Superblock-Offset 0x00)", "(GDT-Offset 0x08)", "(Offset 0x00)" and wrap offset info
const offsetPattern = /(\((Boot-Offset|MFT-Header-Offset|Superblock-Offset|GDT-Offset|Offset) [^)]+\))/g;
return label.replace(offsetPattern, '<span class="offset-info">$1</span>');
};
@@ -57,8 +57,8 @@ export class BaseFilesystem {
// Helper function to format labels with offset information
const formatLabel = (label) => {
// Match patterns like "(Boot-Offset 0x00)", "(MFT-Header-Offset 0x14)", "(Offset 0x00)" and wrap offset info
const offsetPattern = /(\((Boot-Offset|MFT-Header-Offset|Offset) [^)]+\))/g;
// Match patterns like "(Boot-Offset 0x00)", "(MFT-Header-Offset 0x14)", "(Superblock-Offset 0x00)", "(GDT-Offset 0x08)", "(Offset 0x00)" and wrap offset info
const offsetPattern = /(\((Boot-Offset|MFT-Header-Offset|Superblock-Offset|GDT-Offset|Offset) [^)]+\))/g;
return label.replace(offsetPattern, '<span class="offset-info">$1</span>');
};
@@ -164,6 +164,35 @@ export class BaseFilesystem {
throw new Error('calculate method must be implemented by subclass');
}
// Validate that input values are within reasonable ranges
validateInputRanges(variantId, values) {
const variant = this.variants.find(v => v.id === variantId);
if (!variant) return { valid: true, errors: [] };
const errors = [];
// Basic sanity checks that can be applied to all filesystems
// Check for extremely large values that would cause issues
const maxSafeValue = Number.MAX_SAFE_INTEGER / 1024; // Allow some headroom
Object.entries(values).forEach(([key, value]) => {
if (typeof value === 'number' && value > maxSafeValue) {
errors.push(`${key}: Wert zu groß (${value})`);
}
});
return {
valid: errors.length === 0,
errors: errors
};
}
// Abstract method for subclasses to override with specific validation
validateFilesystemSpecific(variantId, values) {
// Subclasses can override this for filesystem-specific validation
return { valid: true, errors: [] };
}
// Setup input event listeners for this filesystem
setupInputListeners(variantId) {
const variant = this.variants.find(v => v.id === variantId);
@@ -196,7 +225,8 @@ export class BaseFilesystem {
variant.constants.forEach(constant => {
const element = document.getElementById(constant.id);
if (element) {
values[constant.id] = parseHex(element.value) || 0;
const parsedValue = parseHex(element.value);
values[constant.id] = parsedValue !== null ? parsedValue : 0;
}
});
@@ -204,7 +234,8 @@ export class BaseFilesystem {
variant.inputs.forEach(input => {
const element = document.getElementById(input.id);
if (element) {
values[input.id] = parseHex(element.value);
const parsedValue = parseHex(element.value);
values[input.id] = parsedValue !== null ? parsedValue : 0;
}
});