The generator expects that parser ensures that string literals are valid as they are:
|
buf.write(format_args!("\"{}\"", s.content)); |
That expectation is sane, because it's in the parser's contract:
|
pub struct StrLit<'a> { |
|
/// the unparsed (but validated) content |
|
pub content: &'a str, |
The parser has to reject a CR if not followed by NL: https://doc.rust-lang.org/reference/tokens.html#string-literals
Issue: https://issues.oss-fuzz.com/issues/424227903
Artifact:
data:application/octet-steam;base64,////e3sgKCIgDSAiKX19/yAg/2n/ICA=
Formatted test case:
#[test]
fn test() -> Result<(), syn::Error> {
let input = quote! {
#[template(ext = "", source = "{{ (\" \r \")}}")]
// ^^ not followed by `\n`
enum i {}
};
let output = derive_template(input, import_askama);
let _: syn::File = syn::parse2(output)?;
Ok(())
}
The generator expects that parser ensures that string literals are valid as they are:
askama/askama_derive/src/generator/expr.rs
Line 717 in 163d978
That expectation is sane, because it's in the parser's contract:
askama/askama_parser/src/lib.rs
Lines 548 to 550 in 163d978
The parser has to reject a CR if not followed by NL: https://doc.rust-lang.org/reference/tokens.html#string-literals
Issue: https://issues.oss-fuzz.com/issues/424227903
Artifact:
Formatted test case: