fix(plex): handle malformed lyrics XML

This commit is contained in:
edde746
2026-07-16 14:36:48 +02:00
parent b7cd4e5e9c
commit ac9a5914a2
2 changed files with 7 additions and 1 deletions
+1 -1
View File
@@ -22,7 +22,7 @@ Lyrics? parsePlexLyricsResponse(Object? raw) {
if (trimmed.startsWith('<')) { if (trimmed.startsWith('<')) {
try { try {
return _parseXmlLyrics(trimmed); return _parseXmlLyrics(trimmed);
} on XmlParserException { } on XmlException {
return null; return null;
} }
} }
@@ -60,4 +60,10 @@ void main() {
expect(plain!.synced, isFalse); expect(plain!.synced, isFalse);
expect(plain.lines.map((line) => line.text), ['Plain first line', 'Plain second line']); expect(plain.lines.map((line) => line.text), ['Plain first line', 'Plain second line']);
}); });
test('returns null for XML with unclosed tags', () {
final lyrics = parsePlexLyricsResponse('<MediaContainer><Lyrics><Line><Span text="Truncated">');
expect(lyrics, isNull);
});
} }