René Kijewski
3f380721a2
parser: reject illegal raw identifiers in attribute access
2025-06-23 18:31:16 +02:00
René Kijewski
76b26cd5fa
parser: str lit must not be followed by suffix#
...
Resolves <https://issues.oss-fuzz.com/issues/426509683 >.
2025-06-21 19:43:28 +02:00
René Kijewski
5ec46333de
parser: fix {% raw %}
for delimiters starting with -
...
Looking at the code once more I came up with an odd edge case. This PR
fixes it.
2025-06-17 15:29:54 +02:00
René Kijewski
53f4eb0b81
Add missing #[inline]
for <_ as Deref>::deref()
2025-06-17 05:25:40 +02:00
René Kijewski
9c67e2a7d9
parser: implement Lit::parse()
without skip_till()
2025-06-17 05:22:12 +02:00
René Kijewski
61bdb49bc7
parser: implement {% raw %}
without skip_till
...
The implementation is longer than before, but also more correct:
Before, the input `{% raw %}{% endraw }}{% endraw %}` would be a syntax
error, now it renders the string `{% endraw }}`.
2025-06-17 01:01:39 +02:00
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
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
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
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
d531c96d13
parser: recognize/reject prefixed ids and lits in macro calls
2025-06-05 18:44:02 +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
9ee2afecfa
Add support for mutable variables
2025-06-01 16:26:57 +02:00
René Kijewski
377253945e
crate!
etc are invalid macro names
2025-05-23 21:01:00 +02:00
Guillaume Gomez
657dcea10f
Merge pull request #422 from pollend/feature/add-support-for-caller
...
feat: add caller pattern from jinja
2025-05-23 13:57:18 +02:00
René Kijewski
eaccbb02ae
Comparison operators cannot be chained
2025-05-23 01:26:19 +02:00
Guillaume Gomez
06c32d6d18
Allow super
in calls
2025-05-22 23:04:52 +02:00
Michael Pollind
f08ca469c9
add more test add reserved word caller
...
Signed-off-by: Michael Pollind <mpollind@gmail.com>
2025-05-22 22:50:40 +02:00
Michael Pollind
ef489b60f6
add test cases and rework spaces
...
Signed-off-by: Michael Pollind <mpollind@gmail.com>
2025-05-22 22:50:40 +02:00
Michael Pollind
ce73e73720
feat: add caller pattern and adjust syntax to closer match jinja
...
Signed-off-by: Michael Pollind <mpollind@gmail.com>
2025-05-22 22:50:40 +02:00
Michael Pollind
b8c85a07bd
feat: add caller pattern for macro
...
Signed-off-by: Michael Pollind <mpollind@gmail.com>
2025-05-22 22:50:39 +02:00
René Kijewski
f92ed0a074
Deny self
etc. as path element
2025-05-20 21:20:55 +02:00
René Kijewski
1b2c54620e
name
is its own span
2025-05-20 21:19:57 +02:00
Guillaume Gomez
244980e0e9
Prevent crate
, Self
and super
to be used as identifiers
2025-05-20 18:31:08 +02:00
Guillaume Gomez
00f9c7068d
Merge pull request #448 from Kijewski/pr-int-base
...
derive: don't suppress fatal errors in integer parsing
2025-05-19 13:07:37 +02:00
René Kijewski
359da68fa0
derive: don't suppress fatal errors in integer parsing
2025-05-19 11:59:37 +02:00
René Kijewski
75dd2c92f3
Update dependencies
...
* Update version-incompatible dependencies in examples.
* Update version-incompatible dev-dependencies.
* Replaced deprecated `criterion::black_box`.
* Add `features = "simd"` to `winnow`. This adds a transitive
dependency to `memchr`, on which we already depend on directly.
2025-05-18 23:06:41 +02:00
René Kijewski
3775f4e3a3
Use unicode-ident
to determine what is an identifier
...
Resolves <https://github.com/askama-rs/askama/issues/442 >.
The performance is actually slightly better than before. `unicode-ident`
is highly optimized and jump free.
One test from a fuzzer outcome had to be deleted, because it contained
identifiers that weren't actually identifiers. There is still a test
that tests the same problem, but every identifier is simply `x`. In
another fuzzed test a character [`U+E0049`] was removed.
[`U+E0049`]: https://en.wikipedia.org/w/index.php?oldid=1278382889
<details>
<summary>Benchmark results</summary>
```text
$ cd askama_parser && cargo bench
librustdoc/all time: [184.47 µs 185.30 µs 186.08 µs]
thrpt: [75.887 MiB/s 76.207 MiB/s 76.548 MiB/s]
change:
time: [−1.4364% −0.9672% −0.4738%] (p = 0.00 < 0.05)
thrpt: [+0.4761% +0.9767% +1.4573%]
Change within noise threshold.
librustdoc/item_info time: [3.3880 µs 3.3892 µs 3.3906 µs]
thrpt: [46.409 MiB/s 46.428 MiB/s 46.445 MiB/s]
change:
time: [−3.8735% −3.5927% −3.2949%] (p = 0.00 < 0.05)
thrpt: [+3.4071% +3.7266% +4.0296%]
Performance has improved.
librustdoc/item_union time: [20.052 µs 20.087 µs 20.126 µs]
thrpt: [49.044 MiB/s 49.140 MiB/s 49.224 MiB/s]
change:
time: [−2.2419% −1.8647% −1.5113%] (p = 0.00 < 0.05)
thrpt: [+1.5345% +1.9002% +2.2933%]
Performance has improved.
librustdoc/page time: [85.828 µs 86.157 µs 86.518 µs]
thrpt: [71.571 MiB/s 71.871 MiB/s 72.147 MiB/s]
change:
time: [−1.2728% −0.7668% −0.2512%] (p = 0.00 < 0.05)
thrpt: [+0.2518% +0.7727% +1.2892%]
Change within noise threshold.
librustdoc/print_item time: [10.065 µs 10.101 µs 10.138 µs]
thrpt: [93.132 MiB/s 93.469 MiB/s 93.806 MiB/s]
change:
time: [−3.3793% −2.8352% −2.3267%] (p = 0.00 < 0.05)
thrpt: [+2.3821% +2.9180% +3.4975%]
Performance has improved.
librustdoc/short_item_info
time: [9.0741 µs 9.1018 µs 9.1377 µs]
thrpt: [99.148 MiB/s 99.540 MiB/s 99.843 MiB/s]
change:
time: [−4.7480% −4.2335% −3.7763%] (p = 0.00 < 0.05)
thrpt: [+3.9245% +4.4207% +4.9847%]
Performance has improved.
librustdoc/sidebar time: [21.468 µs 21.555 µs 21.648 µs]
thrpt: [57.004 MiB/s 57.252 MiB/s 57.482 MiB/s]
change:
time: [−3.7641% −3.0465% −2.4191%] (p = 0.00 < 0.05)
thrpt: [+2.4791% +3.1423% +3.9114%]
Performance has improved.
librustdoc/source time: [7.9602 µs 7.9780 µs 7.9929 µs]
thrpt: [92.230 MiB/s 92.403 MiB/s 92.609 MiB/s]
change:
time: [−1.6386% −1.0684% −0.5875%] (p = 0.00 < 0.05)
thrpt: [+0.5910% +1.0799% +1.6659%]
Change within noise threshold.
librustdoc/type_layout_size
time: [4.7821 µs 4.7915 µs 4.8017 µs]
thrpt: [56.406 MiB/s 56.526 MiB/s 56.637 MiB/s]
change:
time: [−1.9743% −1.4867% −1.0153%] (p = 0.00 < 0.05)
thrpt: [+1.0257% +1.5091% +2.0141%]
Performance has improved.
librustdoc/type_layout time: [15.022 µs 15.051 µs 15.076 µs]
thrpt: [178.57 MiB/s 178.88 MiB/s 179.22 MiB/s]
change:
time: [−1.5028% −1.0358% −0.5705%] (p = 0.00 < 0.05)
thrpt: [+0.5738% +1.0466% +1.5257%]
Change within noise threshold.
```
</details>
2025-05-18 23:04:47 +02:00
René Kijewski
ab798e2482
Allow filters with explicit path
...
IMHO that makes custom filters much easier to use.
2025-05-17 13:20:54 +02:00
René Kijewski
72bbe3ede1
Bump version number to v0.14.0
2025-04-22 23:37:23 +02:00
Guillaume Gomez
6a16256f24
Fix new clippy lints
2025-04-22 11:34:55 +02:00
Guillaume Gomez
04a4d5b020
Update MSRV to 1.83
2025-04-22 11:34:55 +02:00
René Kijewski
b402936db3
generator: add named arguments for filters
2025-04-21 23:11:24 +02:00
René Kijewski
697862a76c
Bump version number to 0.13.0
2025-03-27 17:22:37 +01:00
René Kijewski
19f6582308
Bump version number to v0.13.0-pre.0
2025-03-17 21:32:27 +01:00
Guillaume Gomez
3b52c907c3
Rename rinja
into askama
2025-03-11 19:31:06 +01:00
Guillaume Gomez
2d80cc3524
Rename everything to rinja
2024-06-17 15:58:52 +02:00
Dirkjan Ochtman
1170d54c3b
parser: improve parse error structure
2024-06-07 12:12:15 +02:00
Guillaume Gomez
34f84dc10f
Add support for elif
( #1057 )
...
Co-authored-by: René Kijewski <rene.kijewski@fu-berlin.de>
2024-05-23 14:27:42 +02:00
Dirkjan Ochtman
627d58bc3b
parser: simplify ErrorContext construction
2024-05-21 11:26:21 +02:00
Dirkjan Ochtman
c3582f5d89
parser: attach unclosed error creation to ErrorContext
2024-05-21 11:26:21 +02:00
Dirkjan Ochtman
cbe8ac3c9e
parser: order inherent impl before trait impls
2024-05-21 11:26:21 +02:00
René Kijewski
c1366e0fd8
Re-add {% set %}
as alias for {% let %}
...
Commit [615fb82] introduced a regression. `{% set %}` and `{% let %}`
should be interchangeable, but only the latter syntax works.
This PR fixes the problem, and adds a regression test.
[615fb82]: <615fb82c65
>
2024-05-18 09:14:23 +02:00
René Kijewski
38a2a86e55
Better error messages for truncated files
2024-05-17 18:29:47 +02:00
René Kijewski
615fb82c65
Speed-up node selection
2024-05-16 18:30:33 +02:00