mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-15 16:10:38 +00:00
Fix panic with 8 in octal escape (#8356)
**Summary** The digits for an octal escape are 0 to 7, not 0 to 8, fixing the panic in #8355 **Test plan** Regression test parser fixture
This commit is contained in:
parent
b6c4074836
commit
daea870c3c
2 changed files with 38 additions and 1 deletions
|
@ -114,7 +114,7 @@ impl<'a> StringParser<'a> {
|
|||
let mut len = 1;
|
||||
|
||||
while len < 3 {
|
||||
let Some(b'0'..=b'8') = self.peek_byte() else {
|
||||
let Some(b'0'..=b'7') = self.peek_byte() else {
|
||||
break;
|
||||
};
|
||||
|
||||
|
@ -885,6 +885,15 @@ mod tests {
|
|||
insta::assert_debug_snapshot!(parse_ast);
|
||||
}
|
||||
|
||||
/// <https://github.com/astral-sh/ruff/issues/8355>
|
||||
#[test]
|
||||
fn test_dont_panic_on_8_in_octal_escape() {
|
||||
let source = r"bold = '\038[1m'";
|
||||
let parse_ast = parse_suite(source, "<test>").unwrap();
|
||||
|
||||
insta::assert_debug_snapshot!(parse_ast);
|
||||
}
|
||||
|
||||
macro_rules! test_aliases_parse {
|
||||
($($name:ident: $alias:expr,)*) => {
|
||||
$(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue