{"record":{"id":"d2e8bc9c561a6b5a","repo":"BigPizzaV3/CodexPlusPlus","slug":"error-d2e8bc","errorCode":null,"errorMessage":"无效的市场主题下载文件名","messagePattern":"无效的市场主题下载文件名","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codex-plus-core/src/dream_skin_market.rs","lineNumber":326,"sourceCode":"        });\n    }\n    let records: MarketInstallRecords = serde_json::from_slice(&std::fs::read(path)?)?;\n    if records.schema_version != market_schema_version() {\n        bail!(\"不支持的主题市场安装记录版本\");\n    }\n    Ok(records)\n}\n\nfn record_market_install(state_dir: &Path, id: &str, version: &str) -> anyhow::Result<()> {\n    let mut records = read_install_records(state_dir)?;\n    records.themes.insert(id.to_string(), version.to_string());\n    let bytes = serde_json::to_vec_pretty(&records)?;\n    crate::settings::atomic_write(&state_dir.join(MARKET_INSTALLS_FILE), &bytes)\n}\n\nfn market_download_path(state_dir: &Path, id: &str, extension: &str) -> anyhow::Result<PathBuf> {\n    if !valid_theme_id(id) || !matches!(extension, \"png\" | \"jpg\" | \"gif\" | \"bmp\" | \"webp\") {\n        bail!(\"无效的市场主题下载文件名\");\n    }\n    Ok(state_dir\n        .join(\"dream-skin/market/downloads\")\n        .join(format!(\"{id}.{extension}\")))\n}\n\nfn market_asset_url(base_url: &str, relative: &str) -> anyhow::Result<String> {\n    validate_market_path(relative)?;\n    let base = reqwest::Url::parse(base_url).context(\"主题市场基础地址无效\")?;\n    let joined = base.join(relative).context(\"主题市场资源地址无效\")?;\n    if joined.scheme() != base.scheme() || joined.host_str() != base.host_str() {\n        bail!(\"主题市场资源地址越界\");\n    }\n    Ok(joined.to_string())\n}\n\nfn validate_market_path(value: &str) -> anyhow::Result<()> {\n    if value.is_empty()","sourceCodeStart":308,"sourceCodeEnd":344,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/crates/codex-plus-core/src/dream_skin_market.rs#L308-L344","documentation":"`market_download_path` constructs the on-disk path for a downloaded market theme asset (`<state>/dream-skin/market/downloads/<id>.<ext>`) and validates both parts first: the theme id must pass `valid_theme_id` and the file extension must be one of `png`, `jpg`, `gif`, `bmp`, `webp`. Anything else is rejected to prevent path traversal and writing non-image data under the downloads directory.","triggerScenarios":"`install_market_theme_from_base` calls `market_download_path` with a theme id that fails `valid_theme_id` (empty, wrong charset, too long) or a URL/manifest extension outside the allowed image set (e.g. `zip`, `svg`, `jpeg`, ``, or an extension containing path characters).","commonSituations":"A market manifest advertising a theme asset with an unexpected extension (`svg`, `webp2`, `jpeg`); a manifest theme id that was hand-edited to contain `/`, `..`, or non-ASCII characters; a compromised or buggy market server listing malicious ids.","solutions":["Check the theme's asset URLs in the manifest: ensure they end in one of png/jpg/gif/bmp/webp and fix the manifest or server file naming otherwise.","Verify the theme id passes the app's id rules (alphanumeric with `-`, `_`, `.` segments, no traversal); correct the manifest id if it was hand-edited.","If the server serves a valid image under an unsupported extension (e.g. `jpeg`), rename/republish it with a canonical extension.","If a genuinely new format must be supported, extend the `matches!(extension, ...)` allowlist in `market_download_path` upstream."],"exampleFix":"// manifest theme asset URL\n// before\n\"image\": \"assets/banner.jpeg\"\n// after\n\"image\": \"assets/banner.jpg\"","handlingStrategy":"validation","validationCode":"fn valid_download_name(id: &str, ext: &str) -> bool {\n    let id_ok = !id.is_empty()\n        && id.bytes().all(|b| b.is_ascii_alphanumeric() || matches!(b, b'-' | b'_' | b'.'))\n        && !id.contains('..');\n    id_ok && matches!(ext, \"png\" | \"jpg\" | \"gif\" | \"bmp\" | \"webp\")\n}","typeGuard":"fn is_allowed_image_ext(url: &str) -> Option<&str> {\n    let ext = url.rsplit('.').next()?;\n    matches!(ext, \"png\" | \"jpg\" | \"gif\" | \"bmp\" | \"webp\").then_some(ext)\n}","tryCatchPattern":"match install_market_theme_from_base(...).await {\n    Err(e) if e.to_string().contains(\"下载文件名\") => {\n        eprintln!(\"theme asset id/extension rejected; check manifest URLs\");\n    }\n    other => other?,\n}","preventionTips":["Publish theme assets only with canonical extensions png/jpg/gif/bmp/webp (use .jpg not .jpeg)","Validate theme ids against the same charset rules before adding them to a manifest","Reject absolute or traversal-style ids at manifest authoring time","Treat this error as a sign of a tampered manifest and refetch from a trusted source"],"tags":["validation","filename","path-safety","rust"],"backgroundTag":"invalid-identifier-format","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"}