BigPizzaV3/CodexPlusPlus · error
主题包文件名不安全:
Error message
主题包文件名不安全:{name} What it means
validate_archive_entry_name enforces a safe shape for archive entry names: no whitespace padding, no NUL or ':' characters, no '.'/'..' path segments, and at most two non-empty '/'-separated segments unless under __MACOSX/. Violating any of these yields this error.
Solutions
- Flatten the package to files at the root or inside a single theme directory (one level).
- Remove '.'/'..' segments and special characters (NUL, ':') from entry names.
- Repack the archive; keep macOS metadata under __MACOSX/ or strip it entirely.
Example fix
// before: 'theme/assets/sub/bg.png' (3 segments) // after: 'theme/bg.png' or 'bg.png'
Defensive patterns
Strategy: validation
Validate before calling
fn entry_shape_safe(name: &str) -> bool {
name == name.trim()
&& !name.contains(['\0', ':'])
&& !name.split('/').any(|p| p == "." || p == "..")
&& (name.starts_with("__MACOSX/")
|| name.split('/').filter(|p| !p.is_empty()).count() <= 2)
} Try / catch
match validate_and_read_package(path, platform) {
Ok(pkg) => install(pkg),
Err(e) if e.to_string().contains("文件名不安全") => eprintln!("flatten package to root files or a single theme dir"),
Err(e) => return Err(e),
} Prevention
- Keep packages flat: root files or one theme folder.
- Strip __MACOSX metadata or keep it under __MACOSX/.
- Lint entry names in the packaging script.
When it happens
Trigger: validate_and_read_package reads an entry whose name has leading/trailing whitespace, contains '\0' or ':', contains a '.' or '..' segment, or has 3+ path segments (outside __MACOSX/).
Common situations: Zips created with nested folder trees (theme/assets/sub/file.png); names with drive letters like 'C:'; archives padded by buggy tooling; macOS junk entries (allowed only under __MACOSX/).
Understand the failure class
Background: Path traversal blocked: "path escapes the workspace" and "outside site root" errors when a path will not stay inside its allowed directory — this error's family across 26 libraries.
Related errors
AI-assisted analysis of BigPizzaV3/CodexPlusPlus@b1ed92e5e4 (2026-09-19).
Data as JSON: /api/errors/f1e81f5ddf401fd0.
Report an issue: GitHub.
Appendix: source
Thrown at crates/codex-plus-core/src/dream_skin_package.rs:827
}
seen.contains("blur")
}
fn parse_json<T: serde::de::DeserializeOwned>(bytes: &[u8], label: &str) -> anyhow::Result<T> {
serde_json::from_slice(bytes).with_context(|| format!("{label} 不是有效 JSON"))
}
fn validate_archive_entry_name(name: &str) -> anyhow::Result<()> {
if name.is_empty() || name.starts_with('/') || name.contains('\\') {
bail!("主题包路径不安全:{name}");
}
if name != name.trim()
|| name.contains(['\0', ':'])
|| name.split('/').any(|part| part == "." || part == "..")
|| (!name.starts_with("__MACOSX/")
&& name.split('/').filter(|part| !part.is_empty()).count() > 2)
{
bail!("主题包文件名不安全:{name}");
}
Ok(())
}
fn normalize_package_entries(
entries: Vec<(String, Option<Vec<u8>>)>,
) -> anyhow::Result<std::collections::BTreeMap<String, Vec<u8>>> {
let content_entries = entries
.into_iter()
.filter_map(|(name, content)| content.map(|content| (name, content)))
.collect::<Vec<_>>();
if content_entries.is_empty() {
bail!("Dream Skin 主题包为空");
}
let root_files = content_entries.iter().any(|(name, _)| !name.contains('/'));
let prefix = if root_files {
if content_entries.iter().any(|(name, _)| name.contains('/')) {View on GitHub (pinned to b1ed92e5e4)