History

fix: validate incoming conifguration keys when interpreting envirnoment variables. (#331)

Sebastian Thiel committed 4 years ago

Commit 0d07ef11 parent 9750b7a1 file · +5 −4Browse files

Unified · Split

git-config/src/file/init/from_env.rs+5−4
@@ -1,7 +1,6 @@
1use std::convert::TryFrom;
1use std::{borrow::Cow, path::PathBuf};2use std::{borrow::Cow, path::PathBuf};
2 3
3use bstr::BString;
4
5use crate::{4use crate::{
6 file::{from_paths, init::resolve_includes},5 file::{from_paths, init::resolve_includes},
7 parse::section,6 parse::section,
@@ -27,6 +26,8 @@ pub enum Error { · 19 unmodified lines
27 FromPathsError(#[from] from_paths::Error),26 FromPathsError(#[from] from_paths::Error),
28 #[error(transparent)]27 #[error(transparent)]
29 Section(#[from] section::header::Error),28 Section(#[from] section::header::Error),
29 #[error(transparent)]
30 Key(#[from] section::key::Error),
30}31}
31 32
32/// Instantiation from environment variables33/// Instantiation from environment variables
@@ -112,8 +113,8 @@ impl File<'static> { · 79 unmodified lines
112 };113 };
113 114
114 section.push(115 section.push(
115 section::Key(BString::from(key).into()),116 section::Key::try_from(key.to_owned())?,
116 git_path::into_bstr(PathBuf::from(value)).as_ref(),117 git_path::os_str_into_bstr(&value).expect("no illformed UTF-8").as_ref(),
117 );118 );
118 }119 }
119 None => {120 None => {