Skip to content

Commit

Permalink
feat(wasi) Allow the = sign in the environment variable value.
Browse files Browse the repository at this point in the history
Having `a=b` means that the environment variable key is `a`, and its
value is `b`.

Having `a=b=c` means that the key is `a` and its value is `b=c`.

It's OK to get this, e.g. within a CGI context where values can hold
strings such as `sec-ch-ua: "Chromium;v=86"` etc. See
wasmerio#1708 for a longer
explanation.
  • Loading branch information
Hywan committed Oct 26, 2020
1 parent 7eddb46 commit a1457de
Showing 1 changed file with 8 additions and 26 deletions.
34 changes: 8 additions & 26 deletions lib/wasi/src/state/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,33 +328,15 @@ impl WasiStateBuilder {
}
}
}

for env in self.envs.iter() {
let mut eq_seen = false;
for b in env.iter() {
match *b {
b'=' => {
if eq_seen {
return Err(WasiStateCreationError::EnvironmentVariableFormatError(
format!(
"found '=' in env var string \"{}\" (key=value)",
std::str::from_utf8(env)
.unwrap_or("Inner error: env var is invalid_utf8!")
),
));
}
eq_seen = true;
}
0 => {
return Err(WasiStateCreationError::EnvironmentVariableFormatError(
format!(
"found nul byte in env var string \"{}\" (key=value)",
std::str::from_utf8(env)
.unwrap_or("Inner error: env var is invalid_utf8!")
),
));
}
_ => (),
}
if env.iter().find(|&&ch| ch == 0).is_some() {
return Err(WasiStateCreationError::EnvironmentVariableFormatError(
format!(
"found nul byte in env var string \"{}\" (key=value)",
std::str::from_utf8(env).unwrap_or("Inner error: env var is invalid_utf8!")
),
));
}
}

Expand Down

0 comments on commit a1457de

Please sign in to comment.