{"record":{"id":"47bb6d5862d03e88","repo":"GitoxideLabs/gitoxide","slug":"shell-assignment-names-contain-only-ascii-bytes","errorCode":null,"errorMessage":"shell assignment names contain only ASCII bytes","messagePattern":"shell assignment names contain only ASCII bytes","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"gix-command/src/parse.rs","lineNumber":78,"sourceCode":"/// expansions and operators are not interpreted. An assignment is recognized only when its name is an unquoted\n/// shell identifier. Assignment-only input is rejected because it contains no command to execute. Environment\n/// assignment names are strings, while their values, the command, and arguments are converted losslessly to OS\n/// strings or rejected if the platform cannot represent them.\npub fn command_line(input: &BStr) -> Result<Outcome, Error> {\n    let mut words = parse_words(input)?;\n    let assignment_count = words\n        .iter()\n        .take_while(|word| word.assignment_separator.is_some())\n        .count();\n    let mut args = words.split_off(assignment_count).into_iter().map(|word| word.value);\n    let command = into_os_string(args.next().ok_or(Error::MissingCommand)?)?;\n    let env = words\n        .into_iter()\n        .map(|word| {\n            let separator = word.assignment_separator.expect(\"only recognized assignments remain\");\n            Ok((\n                String::from_utf8(word.value[..separator].to_owned())\n                    .expect(\"shell assignment names contain only ASCII bytes\"),\n                into_os_string(word.value[separator + 1..].to_owned().into())?,\n            ))\n        })\n        .collect::<Result<_, Error>>()?;\n    Ok(Outcome {\n        env,\n        command,\n        args: args.map(into_os_string).collect::<Result<_, _>>()?,\n    })\n}\n\npub(crate) fn arguments(input: &BStr) -> Result<Vec<OsString>, Error> {\n    parse_words(input)?\n        .into_iter()\n        .map(|word| into_os_string(word.value))\n        .collect()\n}\n","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/GitoxideLabs/gitoxide/blob/e73179060badf27222d790981fac3f84c1830a7e/gix-command/src/parse.rs#L60-L96","documentation":"After an assignment separator is found, the variable NAME portion is decoded as UTF-8 and the code asserts shell assignment names are pure ASCII. A non-UTF8/ASCII byte in the assignment name (e.g. from odd shell quoting or binary content before `=`) panics instead of producing an error.","triggerScenarios":"Parsing a command line whose environment assignment name (the text before `=`) contains non-ASCII or invalid UTF-8 bytes, e.g. `VÄR=1 cmd` passed as raw bytes.","commonSituations":"Locale/encoding mismatches when building command strings on non-UTF8 filesystems; scripts embedding non-ASCII variable names; byte-level manipulation of command strings.","solutions":["Ensure environment variable names in the command string are ASCII (standard for POSIX shells anyway)","Sanitize or validate the command string bytes before parsing","Handle it upstream: split assignments yourself and pass env explicitly via Outcome/env APIs","File a bug requesting a graceful error instead of a panic for non-ASCII names"],"exampleFix":"// before\nString::from_utf8(word.value[..separator].to_owned())\n    .expect(\"shell assignment names contain only ASCII bytes\")\n// after\nString::from_utf8(word.value[..separator].to_owned())\n    .map_err(|_| Error::InvalidAssignmentName)?","handlingStrategy":"validation","validationCode":"// Ensure assignment names are ASCII before parsing:\nfn ascii_names_ok(cmd: &[u8]) -> bool {\n    cmd.split(|b| *b == b'=').next()\n        .map(|name| name.is_ascii() && !name.is_empty())\n        .unwrap_or(false)\n}","typeGuard":"fn is_ascii_name(name: &[u8]) -> bool { !name.is_empty() && name.iter().all(|b| b.is_ascii_alphanumeric() || *b == b'_') }","tryCatchPattern":null,"preventionTips":["Keep environment variable names ASCII","Normalize encodings before passing command strings on non-UTF8 filesystems","Prefer passing env via explicit maps rather than inline assignments","Validate command strings in tests with non-ASCII fixtures"],"tags":["panic","utf-8","encoding","shell"],"backgroundTag":"invalid-argument-format","analyzedSha":"e73179060badf27222d790981fac3f84c1830a7e","analyzedAt":"2026-09-08T11:26:50.865Z","contentChangedAt":"2026-09-08T11:26:50.865Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}