mirror of
https://github.com/askama-rs/askama.git
synced 2025-09-27 13:00:57 +00:00
parser: r#_
is not a valid identifier
Resolves <https://issues.oss-fuzz.com/issues/439492383>.
This commit is contained in:
parent
4025323c8d
commit
8d5f3a5290
@ -9,9 +9,8 @@ use winnow::token::{any, one_of, take, take_until};
|
|||||||
use crate::node::CondTest;
|
use crate::node::CondTest;
|
||||||
use crate::{
|
use crate::{
|
||||||
CharLit, ErrorContext, HashSet, InputStream, Num, ParseResult, PathOrIdentifier, StrLit,
|
CharLit, ErrorContext, HashSet, InputStream, Num, ParseResult, PathOrIdentifier, StrLit,
|
||||||
StrPrefix, WithSpan, can_be_variable_name, char_lit, cut_error, filter, identifier,
|
StrPrefix, WithSpan, char_lit, cut_error, filter, identifier, is_rust_keyword, keyword,
|
||||||
is_rust_keyword, keyword, not_suffix_with_hash, num_lit, path_or_identifier, skip_ws0,
|
not_suffix_with_hash, num_lit, path_or_identifier, skip_ws0, skip_ws1, str_lit, ws,
|
||||||
skip_ws1, str_lit, ws,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
macro_rules! expr_prec_layer {
|
macro_rules! expr_prec_layer {
|
||||||
@ -1100,7 +1099,7 @@ impl<'a: 'l, 'l> Suffix<'a> {
|
|||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
// a raw identifier like `r#async`
|
// a raw identifier like `r#async`
|
||||||
if !can_be_variable_name(id) {
|
if matches!(id, "self" | "Self" | "super" | "crate" | "_") {
|
||||||
cut_error!(
|
cut_error!(
|
||||||
format!("`{}` cannot be a raw identifier", id.escape_debug()),
|
format!("`{}` cannot be a raw identifier", id.escape_debug()),
|
||||||
span,
|
span,
|
||||||
|
@ -1625,7 +1625,7 @@ fn test_macro_call_illegal_raw_identifier() {
|
|||||||
// Regression test for <https://issues.oss-fuzz.com/issues/435218013>.
|
// Regression test for <https://issues.oss-fuzz.com/issues/435218013>.
|
||||||
let syntax = Syntax::default();
|
let syntax = Syntax::default();
|
||||||
|
|
||||||
for id in ["crate", "self", "Self", "super"] {
|
for id in ["crate", "self", "Self", "super", "_"] {
|
||||||
assert!(
|
assert!(
|
||||||
Ast::from_str(&format!("{{{{ z!(r#{id}) }}}}"), None, &syntax)
|
Ast::from_str(&format!("{{{{ z!(r#{id}) }}}}"), None, &syntax)
|
||||||
.unwrap_err()
|
.unwrap_err()
|
||||||
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user