{"record":{"id":"5664746214e3ae55","repo":"BigPizzaV3/CodexPlusPlus","slug":"sha-256","errorCode":null,"errorMessage":"主题市场包含无效 SHA-256","messagePattern":"主题市场包含无效 SHA-256","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codex-plus-core/src/dream_skin_market.rs","lineNumber":380,"sourceCode":"    Ok(())\n}\n\nfn valid_theme_id(value: &str) -> bool {\n    let bytes = value.as_bytes();\n    (1..=64).contains(&bytes.len())\n        && bytes[0].is_ascii_alphanumeric()\n        && bytes.iter().all(|byte| {\n            byte.is_ascii_lowercase() || byte.is_ascii_digit() || matches!(byte, b'-' | b'_')\n        })\n}\n\nfn validate_sha256(value: &str) -> anyhow::Result<()> {\n    if value.len() != 64\n        || !value\n            .bytes()\n            .all(|byte| byte.is_ascii_digit() || (b'a'..=b'f').contains(&byte))\n    {\n        bail!(\"主题市场包含无效 SHA-256\");\n    }\n    Ok(())\n}\n\nfn verify_sha256(bytes: &[u8], expected: &str, label: &str) -> anyhow::Result<()> {\n    validate_sha256(expected)?;\n    let actual = format!(\"{:x}\", Sha256::digest(bytes));\n    if actual != expected {\n        bail!(\"{label} SHA-256 校验失败\");\n    }\n    Ok(())\n}\n\nfn detect_image_extension(bytes: &[u8]) -> Option<&'static str> {\n    if bytes.starts_with(b\"\\x89PNG\\r\\n\\x1a\\n\") {\n        Some(\"png\")\n    } else if bytes.starts_with(&[0xff, 0xd8, 0xff]) {\n        Some(\"jpg\")","sourceCodeStart":362,"sourceCodeEnd":398,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/f2074595a281bc057525c748175c8eb9805b0673/crates/codex-plus-core/src/dream_skin_market.rs#L362-L398","documentation":"Validation guard in validate_sha256: the expected hash string is not exactly 64 lowercase hex characters. Fires before hash comparison whenever a manifest entry or caller supplies a malformed digest, distinguishing 'badly formatted hash' from 'hash mismatch'.","triggerScenarios":"Thrown at crates/codex-plus-core/src/dream_skin_market.rs:380 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Regenerate the SHA-256 of the asset and store it as 64 lowercase hex chars","Fix the manifest's hash field"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"f2074595a281bc057525c748175c8eb9805b0673","analyzedAt":"2026-08-23T12:52:24.489Z","contentChangedAt":"2026-08-23T12:52:24.489Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}