{"record":{"id":"cd38b3bb9f4b362f","repo":"BigPizzaV3/CodexPlusPlus","slug":"name-cd38b3","errorCode":null,"errorMessage":"主题包背景图片内容与扩展名不一致：{name}","messagePattern":"主题包背景图片内容与扩展名不一致：(.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codex-plus-core/src/dream_skin_package.rs","lineNumber":891,"sourceCode":"            .to_string();\n        if files.insert(normalized.clone(), content).is_some() {\n            bail!(\"主题包包含重复文件：{normalized}\");\n        }\n    }\n    Ok(files)\n}\n\nfn validate_image_content(name: &str, bytes: &[u8]) -> anyhow::Result<()> {\n    let valid = match name {\n        \"background.png\" => bytes.starts_with(&[0x89, b'P', b'N', b'G', 0x0d, 0x0a, 0x1a, 0x0a]),\n        \"background.jpg\" => bytes.starts_with(&[0xff, 0xd8, 0xff]),\n        \"background.webp\" => {\n            bytes.len() >= 12 && &bytes[..4] == b\"RIFF\" && &bytes[8..12] == b\"WEBP\"\n        }\n        _ => false,\n    };\n    if !valid {\n        bail!(\"主题包背景图片内容与扩展名不一致：{name}\");\n    }\n    Ok(())\n}\n\nfn file_limit(name: &str) -> usize {\n    match name {\n        \"manifest.json\" => MANIFEST_LIMIT,\n        \"theme.json\" => THEME_LIMIT,\n        \"theme.css\" => CSS_LIMIT,\n        \"LICENSE.txt\" => LICENSE_LIMIT,\n        \"manifest.sig\" => SIGNATURE_LIMIT,\n        _ => IMAGE_LIMIT,\n    }\n}\n\nfn validate_manifest(manifest: &DreamSkinPackageManifest, platform: &str) -> anyhow::Result<()> {\n    if manifest.package_version != 1 || manifest.skin_api_version != 1 {\n        bail!(\"不支持的 Dream Skin 主题协议版本\");","sourceCodeStart":873,"sourceCodeEnd":909,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/crates/codex-plus-core/src/dream_skin_package.rs#L873-L909","documentation":"validate_image_content checks magic bytes of background images against their declared file name: PNG, JPEG, GIF and WEBP signatures must match. If the bytes do not match the expected format for the entry name (or the name is not a known background image), it bails with this message.","triggerScenarios":"validate_and_read_package reads background.png/jpg/gif/webp whose content fails the signature check — e.g. a file renamed from .txt to .png, an HTML error page saved as .jpg, or a WEBP missing the RIFF/WEBP headers.","commonSituations":"Renaming images without converting them; download links that returned HTML; image processed by a tool that stripped headers; mistakenly packaging a placeholder file.","solutions":["Re-export the image in the format matching its extension and repack the archive.","Verify the file with `file background.png` (or equivalent) before packaging.","Replace placeholder/corrupted files with real image data."],"exampleFix":"# before: background.png is actually a JPEG\nmv background.jpg bg.jpg && mv bg.jpg background.jpg  # use matching name\n# or convert:\nconvert background.jpg background.png","handlingStrategy":"validation","validationCode":"fn has_signature(name: &str, b: &[u8]) -> bool {\n    match name {\n        \"background.png\" => b.len() >= 8 && &b[..8] == b\"\\x89PNG\\r\\n\\x1a\\n\",\n        \"background.jpg\" => b.len() >= 3 && b[..3] == [0xFF, 0xD8, 0xFF],\n        \"background.gif\" => b.len() >= 6 && (&b[..6] == b\"GIF87a\" || &b[..6] == b\"GIF89a\"),\n        \"background.webp\" => b.len() >= 12 && &b[..4] == b\"RIFF\" && &b[8..12] == b\"WEBP\",\n        _ => false,\n    }\n}","typeGuard":null,"tryCatchPattern":"match validate_and_read_package(path, platform) {\n    Ok(pkg) => install(pkg),\n    Err(e) if e.to_string().contains(\"内容与扩展名不一致\") => eprintln!(\"re-export image with matching format\"),\n    Err(e) => return Err(e),\n}","preventionTips":["Run `file` on images before packaging.","Never rename images across formats without converting.","Verify downloads are actual image bytes."],"tags":["image","validation","content-type"],"backgroundTag":"schema-validation-failed","analyzedSha":"b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6","analyzedAt":"2026-09-19T23:35:21.129Z","contentChangedAt":"2026-09-19T23:35:21.129Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}