fix(ncm): tag 嵌入按实际容器拒绝 MP4/M4A(ID3v2 前缀会破坏 MP4 容器)
download 扩展名在 type 非 flac 时一律落 mp3;若服务端降级返回 MP4/M4A("....ftyp"), 给文件加 ID3v2 头会破坏容器。ncm_tag_embed_file 现读 12 字节 magic:fLaC → VORBIS_COMMENT, "ftyp" → NCM_ERR_ARG 拒绝(调用方 commit 裸流),其余按 MP3 处理。 test_ncm_tag 增 2 条断言(拒绝 + 原文件不变)→ 53 PASS / 0 FAIL,0 warning。
This commit is contained in:
1 parent
39465ea1ef
commit
a9c94c7221
2 files changed
+14
-3
No files matched your search
@@ -347,6 +347,13 @@ static void test_edges(void)
|
||||
snprintf(tmp, sizeof tmp, "%s.tag.tmp", path);
|
||||
CHECK(stat(tmp, &st) != 0, "no .tag.tmp left behind");
|
||||
}
|
||||
/* MP4/M4A("....ftyp")不是 mp3:ID3v2 前缀会破坏 MP4 容器 → 必须拒绝(降级裸流) */
|
||||
snprintf(path, sizeof path, TMPDIR_PREFIX "/fake.m4a.mp3");
|
||||
file_put(path, "\x00\x00\x00\x20""ftypisom\x00\x00\x00\x00", 16);
|
||||
CHECK(ncm_tag_embed_file(path, "mp3", &m) != 0, "MP4 container rejected (no ID3 prefix)");
|
||||
before = file_slurp(path, &blen);
|
||||
CHECK(blen == 16 && memcmp(before + 4, "ftyp", 4) == 0, "MP4 file unchanged");
|
||||
free(before);
|
||||
/* 不存在的文件 */
|
||||
CHECK(ncm_tag_embed_file(TMPDIR_PREFIX "/nope.mp3", "mp3", &m) != 0, "missing file -> error");
|
||||
CHECK(ncm_tag_read_file(TMPDIR_PREFIX "/nope.mp3", &m) == NCM_ERR_NOENT,
|
||||
|
||||
Reference in new issue
Block a user