mirror of
https://github.com/OMGeeky/confique.git
synced 2026-01-01 09:10:18 +01:00
Add check for = or null bytes in env variable key
This commit is contained in:
@@ -302,7 +302,15 @@ impl Parse for InternalAttr {
|
||||
let _: Token![=] = input.parse()?;
|
||||
let key: syn::LitStr = input.parse()?;
|
||||
assert_empty(input)?;
|
||||
Ok(Self::Env(key.value()))
|
||||
let value = key.value();
|
||||
if value.contains('=') || value.contains('\0') {
|
||||
Err(syn::Error::new(
|
||||
key.span(),
|
||||
"environment variable key must not contain '=' or null bytes",
|
||||
))
|
||||
} else {
|
||||
Ok(Self::Env(value))
|
||||
}
|
||||
}
|
||||
|
||||
_ => Err(syn::Error::new(ident.span(), "unknown confique attribute")),
|
||||
|
||||
Reference in New Issue
Block a user