fix: handle UTF BOM in lyrics and playlist files (#4637)

* fix: handle UTF-8 BOM in lyrics and playlist files

Added UTF-8 BOM (Byte Order Mark) detection and stripping for external lyrics files and playlist files. This ensures that files with BOM markers are correctly parsed and recognized as synced lyrics or valid playlists.

The fix introduces a new ioutils package with UTF8Reader and UTF8ReadFile functions that automatically detect and remove UTF-8, UTF-16 LE, and UTF-16 BE BOMs. These utilities are now used when reading external lyrics and playlist files to ensure consistent parsing regardless of BOM presence.

Added comprehensive tests for BOM handling in both lyrics and playlists, including test fixtures with actual BOM markers to verify correct behavior.

* test: add test for UTF-16 LE encoded LRC files

Signed-off-by: Deluan <deluan@navidrome.org>

---------

Signed-off-by: Deluan <deluan@navidrome.org>
This commit is contained in:
Deluan Quintão
2025-10-31 09:07:23 -04:00
committed by GitHub
parent 0bdd3e6f8b
commit 91fab68578
10 changed files with 218 additions and 4 deletions
+4
View File
@@ -0,0 +1,4 @@
[00:00.00] 作曲 : 柏大輔
NOTE: This file intentionally contains a UTF-8 BOM (Byte Order Mark) at byte 0.
This tests BOM handling in lyrics parsing (GitHub issue #4631).
The BOM bytes are: 0xEF 0xBB 0xBF
Binary file not shown.
Binary file not shown.
+6
View File
@@ -0,0 +1,6 @@
#EXTM3U
# NOTE: This file intentionally contains a UTF-8 BOM (Byte Order Mark) at the beginning
# (bytes 0xEF 0xBB 0xBF) to test BOM handling in playlist parsing.
#PLAYLIST:Test Playlist
#EXTINF:123,Test Artist - Test Song
test.mp3