-
Notifications
You must be signed in to change notification settings - Fork 204
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
YAML: incorrect parsing of curly brackets #439
Comments
Hi! I'll leave this open for discoverability until the yaml lib is fixed. If someone wants to contribute a test for this, I'd love to have that! |
Unable to reproduce (not much of a reproduction example given) with:
More context is required for this to be valid/reproducible. Yaml file: key: "${env_var}" Rust reproduction use config::{Config, File, FileFormat};
use serde::Deserialize;
fn main() {
let sources = ConfigSource::vec_example();
for s in sources {
let c = s.get_config();
let test: Test = c.try_deserialize().unwrap();
println!("{:#?}", test);
}
}
#[allow(dead_code)]
#[derive(Debug, Deserialize)]
struct Test {
key: String,
}
fn make<T>(source: T) -> Config
where
T: config::Source + Send + Sync + 'static,
{
Config::builder()
.add_source(source)
.build()
.unwrap()
}
// Overkill:
enum ConfigSource {
String(File<config::FileSourceString, FileFormat>),
File(File<config::FileSourceFile, FileFormat>),
}
impl ConfigSource {
fn vec_example() -> Vec<ConfigSource> {
vec![
ConfigSource::String(
File::from_str(r#"key: "${env_var}""#, FileFormat::Yaml)
),
ConfigSource::File(
File::new("test.yml", FileFormat::Yaml)
)
]
}
fn get_config(self) -> Config {
match self {
Self::String(s) => make(s),
Self::File(f) => make(f),
}
}
} Output:
Raw
|
When parsing curly brackets, even as a string (
"${env_var}"
), it decodes the curly brackets to it's ASCII code. This is probably a bug of the underlying yaml library (yaml-rust).I solved it by not using curly brackets.
The text was updated successfully, but these errors were encountered: