MEDIUM: - #7 API-Key XOR-obfuskiert in app_config.dart (strings zeigen keinen Klartext) - #8 Navidrome-Download: Status-Code-Prüfung + hatValideMagicBytes() + istKorrupt - #9 _sucheYtUrls() sendet jetzt X-API-Key Header an YT-Proxy - #10 Log-Puffer auf 500 Einträge gecappt (älteste verwerfen) - #11 MeloLogger.cloudToken entfernt (war nie gesetzt, toter Code) - #12 TextEditingController-Leaks in 4 Files: ctrl.dispose() nach showDialog - #13 Cloud-Sync: Last-Write-Wins Konfliktauflösung dokumentiert LOW: - #14 API-Versionierung: alle /api/cloud/ → /api/v1/cloud/ - #15 Auto-Scan: nur /Music, /Download, nicht ganz /storage - #16 2 pre-existing flutter analyze Infos behoben (curly_braces, use_build_context_synchronously) flutter analyze: No issues found.
50 lines
1.6 KiB
Dart
50 lines
1.6 KiB
Dart
import 'dart:io';
|
|
|
|
/// Gemeinsame Utility: Validiert Magic Bytes von Audiodateien.
|
|
/// Prüft MP3 (ID3v2 + MPEG-Frames), M4A/AAC, FLAC, WAV, OGG.
|
|
///
|
|
/// Prüft die Magic Bytes einer Audiodatei.
|
|
/// MP3: ID3-Tag (49 44 33) oder MPEG-Frame (FF FB, FF FA, FF F3, FF F2)
|
|
/// M4A/AAC: ftyp-Box (66 74 79 70)
|
|
/// FLAC: fLaC (66 4C 61 43)
|
|
/// WAV: RIFF (52 49 46 46)
|
|
/// OGG: OggS (4F 67 67 53)
|
|
bool hatValideMagicBytes(File file) {
|
|
try {
|
|
if (!file.existsSync()) return false;
|
|
final bytes = file.readAsBytesSync().take(16).toList();
|
|
if (bytes.length < 4) return false;
|
|
|
|
// ID3v2 Tag (MP3 mit Metadaten) — Bytes: 49 44 33
|
|
if (bytes[0] == 0x49 && bytes[1] == 0x44 && bytes[2] == 0x33) return true;
|
|
|
|
// MP3 ohne ID3: MPEG Audio Frame Sync (FF FB, FF FA, FF F3, FF F2)
|
|
if (bytes[0] == 0xFF && (bytes[1] & 0xFE) == 0xFA) return true; // MPEG v1
|
|
if (bytes[0] == 0xFF && bytes[1] == 0xF3) return true; // MPEG v2 / v2.5
|
|
if (bytes[0] == 0xFF && bytes[1] == 0xF2) return true; // MPEG v2 / v2.5
|
|
|
|
// M4A/AAC: ftyp-Box
|
|
if (bytes.length >= 8 &&
|
|
bytes[4] == 0x66 && bytes[5] == 0x74 &&
|
|
bytes[6] == 0x79 && bytes[7] == 0x70) {
|
|
return true;
|
|
}
|
|
|
|
// FLAC: fLaC
|
|
if (bytes[0] == 0x66 && bytes[1] == 0x4C &&
|
|
bytes[2] == 0x61 && bytes[3] == 0x43) { return true; }
|
|
|
|
// WAV: RIFF
|
|
if (bytes[0] == 0x52 && bytes[1] == 0x49 &&
|
|
bytes[2] == 0x46 && bytes[3] == 0x46) { return true; }
|
|
|
|
// OGG: OggS
|
|
if (bytes[0] == 0x4F && bytes[1] == 0x67 &&
|
|
bytes[2] == 0x67 && bytes[3] == 0x53) { return true; }
|
|
|
|
return false;
|
|
} catch (_) {
|
|
return false;
|
|
}
|
|
}
|