2614 Commits

Author SHA1 Message Date
René Kijewski
b6acf7b3a8 parser: simplify {# comment #} parsing
`winnow`'s `take_until` with feature `simd` enabled is implemented like
our "optimized" `skip_till`. There is no need to reinvent the wheel.
2025-06-16 23:49:58 +02:00
René Kijewski
568ced0c55 parser: recognize comments in macro calls
Fixes issue <https://issues.oss-fuzz.com/issues/425145246>
2025-06-16 23:49:47 +02:00
Guillaume Gomez
e329f98433
Merge pull request #484 from Kijewski/pr-u+10ffff
parser: U+10FFFF is the highest Unicode codepoint
2025-06-16 16:50:36 +02:00
René Kijewski
b70de9cd73 Unify splitting function, and finish comment sentences 2025-06-15 22:05:24 +02:00
René Kijewski
94e7757078 Filter linebreaksbr only needs core 2025-06-14 15:12:22 +02:00
René Kijewski
b9490c4b5d Filter paragraphbreaks only needs core 2025-06-14 14:57:55 +02:00
René Kijewski
781d88042c Filter linebreaks only needs core 2025-06-14 14:54:19 +02:00
Guillaume Gomez
477bfe4a3c Update information about wordcount filter 2025-06-14 13:18:22 +02:00
Guillaume Gomez
7ff890b14d Make wordcount filter work with core only 2025-06-14 13:18:22 +02:00
Guillaume Gomez
0b7858d78d Rename filters/builtin.rs into filters/core.rs 2025-06-14 13:18:22 +02:00
René Kijewski
00b640c93b parser: better error message for bare CRs 2025-06-13 22:19:17 +02:00
René Kijewski
9ffa6b954c parser: U+10FFFF is the highest Unicode codepoint
Fix a small typo: parsing '\u{123456}` should parse up to 6 characters,
inclusively.
2025-06-13 11:32:51 +02:00
Guillaume Gomez
fc8906ca60
Merge pull request #483 from Kijewski/issue-482
parser: reject isolated CRs in string literals
2025-06-13 11:24:08 +02:00
René Kijewski
341b850351 parser: reject isolated CRs in string literals
According to <https://doc.rust-lang.org/reference/tokens.html#string-literals>.

Fixes <https://github.com/askama-rs/askama/issues/482>.
Fixes <https://issues.oss-fuzz.com/issues/424227903>.
2025-06-13 06:17:12 +02:00
Guillaume Gomez
163d9780bf
Merge pull request #481 from Kijewski/pr-index0
Rename `LoopItem::index` to `LoopItem::index0`
2025-06-11 19:27:03 +02:00
René Kijewski
50e0a96481 Rename LoopItem::index to LoopItem::index0
That's what the element is called in the template syntax.

Also refactor `Generator::visit_attr()` at bit to make it more readable.
Also add `__askama` prefix to `_len`.
2025-06-11 18:53:42 +02:00
Guillaume Gomez
9309acaa01
Merge pull request #479 from Kijewski/issue-425
parser: reject illegal string literals
2025-06-10 19:55:32 +02:00
René Kijewski
878b28b71c parser: truly terrible code was generated in punctuation 2025-06-09 19:24:08 +02:00
René Kijewski
532e343c40 parser: reject illegal string literals 2025-06-09 19:24:08 +02:00
René Kijewski
66ce299a4a parser: in macro calls reject cstrings with NULs 2025-06-09 19:24:07 +02:00
René Kijewski
478d72614e filter reject is not HTML safe 2025-06-06 15:48:04 +02:00
René Kijewski
72b9005cb5 filter: modify reject a bit
* Re-use iterator getting from `{% for %}`'s implementation
* Don't use edition 2024 features
2025-06-06 15:48:04 +02:00
Guillaume Gomez
36fd13d3b2 Apply suggestions 2025-06-06 15:48:04 +02:00
Guillaume Gomez
c6aa9b2e83 Add new reject filter 2025-06-06 15:48:04 +02:00
Guillaume Gomez
c8acf8b270
Merge pull request #476 from Kijewski/issue-475
parser: recognize/reject prefixed ids and lits in macro calls
2025-06-05 21:23:09 +02:00
René Kijewski
d181493084 Fix clippy warning 2025-06-05 18:45:51 +02:00
René Kijewski
d531c96d13 parser: recognize/reject prefixed ids and lits in macro calls 2025-06-05 18:44:02 +02:00
René Kijewski
9bf41656a4 ci: some fixes
* forgot to update source folder in [#473]
* documentation creation was not checked for `askama_escape`
* cluster-fuzz could not [upload sarif file] that contained its outcome
* let all fuzzers run for the same amount of time

[#473]: <https://redirect.github.com/askama-rs/askama/pull/473>
[upload sarif file]: <https://docs.github.com/en/code-security/code-scanning/integrating-with-code-scanning/uploading-a-sarif-file-to-github>
2025-06-03 14:48:37 +02:00
René Kijewski
3a52a2a1c7 book: document all crates on readthedocs 2025-06-03 14:10:26 +02:00
Guillaume Gomez
47c04fca0b
Merge pull request #470 from Kijewski/pr-dedup-filter-with-path
derive: dedupe visit custom filters code
2025-06-02 21:31:14 +02:00
Guillaume Gomez
c2f73a2de1
ci: don't collect filter output into String (#471)
We don't have to care if the output is big. If the user calls a filter
with a big input, then they should know that the output will probably be
even bigger.
2025-06-02 21:30:44 +02:00
René Kijewski
96796cb1aa ci: don't collect filter output into String
We don't have to care if the output is big. If the user calls a filter
with a big input, then they should know that the output will probably be
even bigger.
2025-06-02 00:40:43 +02:00
René Kijewski
988b643c20 derive: dedupe visit custom filters code 2025-06-01 23:56:10 +02:00
Michael Pollind
df54534ae6 bugfix: resolve with macro with call after caller
https://github.com/askama-rs/askama/issues/467

Signed-off-by: Michael Pollind <mpollind@gmail.com>
2025-06-01 21:05:06 +02:00
René Kijewski
0e30499f59 ci: update fuzzing corpus to include derive 2025-06-01 19:14:28 +02:00
René Kijewski
ca50787f92 parser: macro calls need proper tokens
With this PR invalid tokens inside a macro call `macro_name!(..)` are
rejected. Otherwise we might emit invalid code that cannot be parsed by
rust.
2025-06-01 19:14:28 +02:00
Guillaume Gomez
6010cd390f Add documentation for mutable variables 2025-06-01 16:26:57 +02:00
Guillaume Gomez
741ff53a88 Add regression tests for mutable variables 2025-06-01 16:26:57 +02:00
Guillaume Gomez
9ee2afecfa Add support for mutable variables 2025-06-01 16:26:57 +02:00
strickczq
c40e828f03 fix fmt and clippy 2025-05-29 19:00:50 +02:00
strickczq
77b0763679 Track first line across calls and add tests
Fix logic issue where `self.first` was not tracked across calls, causing incorrect indentation.

Replaced `idx` with `is_first_line` flag.

Added `test_indent_chunked` to verify correct behavior.
2025-05-29 19:00:50 +02:00
strickczq
6653662d9e book: remove alloc feature mention for indent filter
Updated the "filters" chapter in the book to remove the mention of the alloc feature requirement for the indent filter, as it no longer relies on memory allocation.
2025-05-29 19:00:50 +02:00
strickczq
6d5473f801 fix alloc imports by indent.rs 2025-05-29 19:00:50 +02:00
strickczq
b54c5666c3 Move indent filter to separate indent.rs file
Relocated the `indent` filter implementation from alloc.rs to a new indent.rs file,
as it no longer requires memory allocation.

Updated module imports and exports in filters/mod.rs to reflect this change.

Removed unused dependencies
    (Cow, Deref, Pin) from alloc.rs.
2025-05-29 19:00:50 +02:00
strickczq
8c6d227ddb Rewrite indent filter to use IndentWriter
Refactored the `indent` filter implementation to introduce the `IndentWriter` struct,
eliminating the need for memory allocation.

Removed the `MAX_LEN` restriction and the `fuzzed_indent_filter` test,
as they are no longer necessary with the new approach.

Fixes #465.
2025-05-29 19:00:50 +02:00
Alexander Zaitsev
08682a3133
docs: Update performance.md (#188)
* docs: Update performance.md

- add documentation about PGO usage for optimizing Rinja's performance
2025-05-28 11:39:03 +02:00
Guillaume Gomez
39b957a1b3 Add issue templates 2025-05-28 03:17:01 +02:00
Guillaume Gomez
f3201cfb21
Merge pull request #456 from sinder38/update-ref-doc
Update `ref` documentation
2025-05-26 22:04:05 +02:00
René Kijewski
429aaf0821 Escape macro names like loop! 2025-05-23 21:01:00 +02:00
René Kijewski
377253945e crate! etc are invalid macro names 2025-05-23 21:01:00 +02:00