dont attempt to deserialize bracketed strings as arrays if they contain more brackets

This commit is contained in:
Robin Appelman 2026-01-03 16:05:51 +01:00
commit 842cf2407c
7 changed files with 22 additions and 4 deletions

View file

@ -7,6 +7,8 @@
array 2
array "3"
windows_path "C:\test\no newline"
bracket_string "[{]"
ignored_bracket_string "[{]"
\\"$translucent" 1 // this is real vdf written by real valve developers
"$envmaptint" .5 .5 .5

View file

@ -43,6 +43,7 @@ enum Expected {
empty: (),
array: Vec<u32>,
windows_path: String,
bracket_string: String,
#[serde(rename = r#"\\"$translucent""#)]
translucent: bool,
#[serde(rename = "$envmaptint")]
@ -255,7 +256,6 @@ fn test_serde_table(path: &str) {
fn test_serde_from_table(path: &str) {
let raw = read_to_string(path).unwrap();
let result = Table::load_from_str(&raw).unwrap();
dbg!(&result);
let material: Expected = from_entry(result.into()).expect("table to material");
insta::assert_ron_snapshot!(format!("table_to_material__{}", path), material);

View file

@ -15,8 +15,10 @@ expression: parsed
"2",
"3",
],
"bracket_string": "[{]",
"empty": "",
"empty quoted": "\"\"",
"ignored_bracket_string": "[{]",
"windows_path": "C:\\test\\no newline",
},
}

View file

@ -10,6 +10,7 @@ r#Resource/specificPanel.res(
3,
],
windows_path: "C:\\test\\no newline",
bracket_string: "[{]",
r#\\"$translucent": true,
r#$envmaptint: (0.5, 0.5, 0.5),
)

View file

@ -10,6 +10,7 @@ r#Resource/specificPanel.res(
3,
],
windows_path: "C:\\test\\no newline",
bracket_string: "[{]",
r#\\"$translucent": true,
r#$envmaptint: (0.5, 0.5, 0.5),
)