{"record":{"id":"3a7706c610ed3763","repo":"jdx/mise","slug":"brew-cask-invalid-font-target","errorCode":null,"errorMessage":"brew-cask: invalid font target '{}'","messagePattern":"brew-cask: invalid font target '(.+?)'","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/system/packages/brew/cask.rs","lineNumber":2904,"sourceCode":"            .filter(|entry| entry.file_type().is_ok_and(|ft| ft.is_dir()))\n            .any(|entry| relative.is_some_and(|path| entry.path().join(path).is_file()));\n        if has_staged_copy {\n            file::remove_file(target)?;\n        }\n    }\n    Ok(())\n}\n\nfn font_target_path(font: &FontArtifact) -> Result<PathBuf> {\n    let name = font_filename(font)?;\n    let name_path = Path::new(&name);\n    if name_path.is_absolute()\n        || name_path\n            .components()\n            .any(|component| matches!(component, Component::ParentDir))\n        || name_path.components().next().is_none()\n    {\n        bail!(\"brew-cask: invalid font target '{}'\", name);\n    }\n    Ok(font_dir().join(name_path))\n}\n\nfn font_dir() -> PathBuf {\n    if cfg!(target_os = \"linux\") {\n        crate::env::XDG_DATA_HOME.join(\"fonts\")\n    } else {\n        crate::dirs::HOME.join(\"Library\").join(\"Fonts\")\n    }\n}\n\n#[cfg(test)]\nfn execute_flight_steps(\n    cask: &Cask,\n    steps: &[FlightStep],\n    staged_path: &Path,\n    appdir: &Path,","sourceCodeStart":2886,"sourceCodeEnd":2922,"githubUrl":"https://github.com/jdx/mise/blob/6f52dcdf99e282ef7a7db68c81301fa4618d0f79/src/system/packages/brew/cask.rs#L2886-L2922","documentation":"font_target_path computes where a font is linked: font_dir().join(name), where name comes from font_filename (the font's explicit target or its source filename). The name must be relative, non-empty, and contain no ParentDir component — otherwise the link would escape the platform font directory (~/.local/share/fonts on Linux, ~/Library/Fonts on macOS). Any violation bails with the computed name.","triggerScenarios":"font target: \"/Library/Fonts/X.ttf\" (absolute), \"../X.ttf\", an empty target with an unnameable source, or any target containing '..' segments.","commonSituations":"Cask authors copying Homebrew ruby syntax that tolerated absolute font targets; templating bugs producing empty or traversal-laden strings.","solutions":["Set the font target to a bare filename (\"Foo.ttf\") or a simple relative subpath","Omit the target so the name is derived from the source file","Strip any leading '/' or '..' from the stanza"],"exampleFix":"# before (cask stanza)\nfont \"FiraCode.ttf\", target: \"/Library/Fonts/FiraCode.ttf\"\n\n# after\nfont \"FiraCode.ttf\"","handlingStrategy":"validation","validationCode":"// Validate the computed font filename before install.\nfn valid_font_name(name: &str) -> bool {\n    let p = Path::new(name);\n    !p.is_absolute()\n        && p.components().next().is_some()\n        && !p.components().any(|c| matches!(c, std::path::Component::ParentDir))\n}","typeGuard":"fn is_bare_font_filename(target: Option<&str>) -> bool {\n    target.map(valid_font_name).unwrap_or(true)\n}","tryCatchPattern":null,"preventionTips":["Write font targets as bare filenames (\"Foo.ttf\")","Omit the target to derive it from the source filename","Never copy absolute font paths from Homebrew ruby casks into this format"],"tags":["brew-cask","font","path-validation","filename"],"backgroundTag":"invalid-filename","analyzedSha":"6f52dcdf99e282ef7a7db68c81301fa4618d0f79","analyzedAt":"2026-08-22T10:14:23.840Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}