mirror of
https://github.com/alacritty/alacritty.git
synced 2026-11-25 23:24:31 +03:00
Fix config import error handling
This commit is contained in:
1 parent
3c3e6870de
commit
92a3d482d0
1 file changed
+12
-5
@@ -191,24 +191,31 @@ fn parse_config(
|
||||
|
||||
/// Load all referenced configuration files.
|
||||
fn load_imports(config: &Value, config_paths: &mut Vec<PathBuf>, recursion_limit: usize) -> Value {
|
||||
let mut merged = Value::Null;
|
||||
|
||||
let imports = match config.get("import") {
|
||||
Some(Value::Sequence(imports)) => imports,
|
||||
_ => return merged,
|
||||
Some(_) => {
|
||||
error!(target: LOG_TARGET_CONFIG, "Invalid import type: expected a sequence");
|
||||
return Value::Null;
|
||||
},
|
||||
None => return Value::Null,
|
||||
};
|
||||
|
||||
// Limit recursion to prevent infinite loops.
|
||||
if !imports.is_empty() && recursion_limit == 0 {
|
||||
error!(target: LOG_TARGET_CONFIG, "Exceeded maximum configuration import depth");
|
||||
return merged;
|
||||
return Value::Null;
|
||||
}
|
||||
|
||||
let mut merged = Value::Null;
|
||||
|
||||
for import in imports {
|
||||
let path = match import {
|
||||
Value::String(path) => PathBuf::from(path),
|
||||
_ => {
|
||||
error!(target: LOG_TARGET_CONFIG, "Encountered invalid configuration file import");
|
||||
error!(
|
||||
target: LOG_TARGET_CONFIG,
|
||||
"Invalid import element type: expected path string"
|
||||
);
|
||||
continue;
|
||||
},
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user