Skip to content

Commit e6eb4e8

Browse files
test: SyntaxDefinition regex shouldn't allow unescaped backslash
Co-authored-by: Cosmic Horror <CosmicHorrorDev@pm.me>
1 parent cbb1326 commit e6eb4e8

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/parsing/yaml_load.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1319,4 +1319,25 @@ mod tests {
13191319
println!("{:?}", valid_indexes);
13201320
assert_eq!(valid_indexes, [0, 1, 5, 6]);
13211321
}
1322+
1323+
#[test]
1324+
fn error_loading_syntax_with_unescaped_backslash() {
1325+
let load_err = SyntaxDefinition::load_from_str(
1326+
r#"
1327+
name: Unescaped Backslash
1328+
scope: source.c
1329+
file_extensions: [test]
1330+
contexts:
1331+
main:
1332+
- match: '\'
1333+
"#,
1334+
false,
1335+
None,
1336+
)
1337+
.unwrap_err();
1338+
match load_err {
1339+
ParseSyntaxError::RegexCompileError(bad_regex, _) => assert_eq!(bad_regex, r"\"),
1340+
_ => panic!("Unexpected error: {load_err}"),
1341+
}
1342+
}
13221343
}

0 commit comments

Comments
 (0)