Normalizes and validates a HashMap of environment variables, sorting keys and rejecting invalid entries.
// Source: https://github.com/herdrdev/herdr | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
use std::collections::HashMap;
pub(super) fn normalize_launch_env(
env: HashMap<String, String>,
) -> Result<Vec<(String, String)>, (String, String)> {
let mut normalized = Vec::with_capacity(env.len());
for (key, value) in env {
if key.is_empty() {
return Err(("invalid_env".into(), "env key must not be empty".into()));
}
if key.contains('=') {
return Err((
"invalid_env".into(),
format!("env key {key} must not contain '='"),
));
}
if key.contains('\0') {
retu
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key