fix(plex): handle malformed lyrics XML
This commit is contained in:
@@ -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);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user