2490 Commits

Author SHA1 Message Date
René Kijewski
c71aead21b parser: understand nested block comments in macro calls
Fixes <https://issues.oss-fuzz.com/issues/427825995>.
2025-06-29 11:21:33 +02:00
Guillaume Gomez
7610b374db
Merge pull request #503 from Kijewski/pr-clippy
Fix clippy warnings for rust 1.90
2025-06-29 11:13:35 +02:00
René Kijewski
83e0f9c9c4 Fix clippy warnings for rust 1.90 2025-06-29 08:52:44 +02:00
dependabot[bot]
d858227e57 build(deps): update console requirement from 0.15.8 to 0.16.0
Updates the requirements on [console](https://github.com/console-rs/console) to permit the latest version.
- [Release notes](https://github.com/console-rs/console/releases)
- [Changelog](https://github.com/console-rs/console/blob/main/CHANGELOG.md)
- [Commits](https://github.com/console-rs/console/compare/0.15.8...0.16.0)

---
updated-dependencies:
- dependency-name: console
  dependency-version: 0.16.0
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-06-29 08:50:56 +02:00
Guillaume Gomez
73bbfa9200
Merge pull request #501 from Kijewski/pr-context_error
parser: un-inline error message generation
2025-06-24 23:20:33 +02:00
René Kijewski
6c32499533 parser: un-inline error message generation
This change cuts 40 to 150 instructions per parsing function that
generates a `ErrorContext`, and reduces the stack usage per function 500
or more bytes.

Also, it's less code you have to read and type per error message.

<details>

<summary>Benchmark results (benches/from_str.rs)</summary>

```text
librustdoc/all          time:   [177.24 µs 177.92 µs 178.56 µs]
                        thrpt:  [79.081 MiB/s 79.369 MiB/s 79.674 MiB/s]
                 change:
                        time:   [−2.3057% −2.0764% −1.8236%] (p = 0.00 < 0.05)
                        thrpt:  [+1.8575% +2.1204% +2.3601%]
                        Performance has improved.

librustdoc/item_info    time:   [3.1792 µs 3.1890 µs 3.1973 µs]
                        thrpt:  [49.216 MiB/s 49.344 MiB/s 49.495 MiB/s]
                 change:
                        time:   [−4.3188% −3.9734% −3.6065%] (p = 0.00 < 0.05)
                        thrpt:  [+3.7414% +4.1378% +4.5137%]
                        Performance has improved.

librustdoc/item_union   time:   [18.237 µs 18.297 µs 18.369 µs]
                        thrpt:  [53.734 MiB/s 53.945 MiB/s 54.123 MiB/s]
                 change:
                        time:   [−3.6142% −3.2857% −2.9748%] (p = 0.00 < 0.05)
                        thrpt:  [+3.0660% +3.3974% +3.7497%]
                        Performance has improved.

librustdoc/page         time:   [83.761 µs 84.102 µs 84.414 µs]
                        thrpt:  [73.355 MiB/s 73.627 MiB/s 73.927 MiB/s]
                 change:
                        time:   [−2.4929% −2.2196% −1.9439%] (p = 0.00 < 0.05)
                        thrpt:  [+1.9825% +2.2700% +2.5566%]
                        Performance has improved.

librustdoc/print_item   time:   [9.5466 µs 9.5528 µs 9.5603 µs]
                        thrpt:  [98.756 MiB/s 98.834 MiB/s 98.898 MiB/s]
                 change:
                        time:   [−1.4294% −1.2085% −0.9713%] (p = 0.00 < 0.05)
                        thrpt:  [+0.9808% +1.2233% +1.4501%]
                        Change within noise threshold.

librustdoc/short_item_info
                        time:   [8.8031 µs 8.8127 µs 8.8204 µs]
                        thrpt:  [102.72 MiB/s 102.80 MiB/s 102.92 MiB/s]
                 change:
                        time:   [−4.3207% −3.9712% −3.6035%] (p = 0.00 < 0.05)
                        thrpt:  [+3.7382% +4.1355% +4.5158%]
                        Performance has improved.

librustdoc/sidebar      time:   [20.181 µs 20.218 µs 20.253 µs]
                        thrpt:  [60.933 MiB/s 61.036 MiB/s 61.150 MiB/s]
                 change:
                        time:   [−2.5827% −2.3381% −2.0839%] (p = 0.00 < 0.05)
                        thrpt:  [+2.1283% +2.3940% +2.6512%]
                        Performance has improved.

librustdoc/source       time:   [7.2338 µs 7.2377 µs 7.2423 µs]
                        thrpt:  [101.79 MiB/s 101.85 MiB/s 101.91 MiB/s]
                 change:
                        time:   [−3.1453% −2.8930% −2.6317%] (p = 0.00 < 0.05)
                        thrpt:  [+2.7028% +2.9792% +3.2475%]
                        Performance has improved.

librustdoc/type_layout_size
                        time:   [4.3755 µs 4.3774 µs 4.3792 µs]
                        thrpt:  [61.847 MiB/s 61.874 MiB/s 61.900 MiB/s]
                 change:
                        time:   [−6.6822% −6.5162% −6.3593%] (p = 0.00 < 0.05)
                        thrpt:  [+6.7912% +6.9704% +7.1607%]
                        Performance has improved.

librustdoc/type_layout  time:   [14.297 µs 14.316 µs 14.331 µs]
                        thrpt:  [187.86 MiB/s 188.06 MiB/s 188.30 MiB/s]
                 change:
                        time:   [−3.2479% −2.8916% −2.6244%] (p = 0.00 < 0.05)
                        thrpt:  [+2.6952% +2.9777% +3.3569%]
                        Performance has improved.
```

</details>
2025-06-24 19:34:23 +02:00
René Kijewski
758a75bc54 parser: import winnow::error::ErrMode 2025-06-24 17:37:22 +02:00
René Kijewski
4f5272406f parser: replace manual i_before with .with_taken() 2025-06-24 15:02:41 +02:00
René Kijewski
1a1b507722 parser: refactor |filter and {% filter %} parsing
Deduplicated and easier to read code.
2025-06-24 15:02:41 +02:00
Guillaume Gomez
ca6573bf56 Rename Expr::Attr into Expr::AssociatedItem 2025-06-24 14:09:34 +02:00
René Kijewski
338369a424 parser: box Expr::Filter to reduce Expr's size 2025-06-24 12:21:41 +02:00
René Kijewski
2086d4f898 parser: introduce askama_parser::expr::Call 2025-06-24 12:21:41 +02:00
René Kijewski
49d4397f51 parser: introduce askama_parser::expr::Range 2025-06-24 12:21:41 +02:00
René Kijewski
9f882e2ca7 parser: introduce askama_parser::expr::BinOp 2025-06-24 12:21:41 +02:00
René Kijewski
edfa31f9cf parser: ensure valid paths in generics 2025-06-23 18:31:16 +02:00
René Kijewski
749d4edd89 Import ErrMode 2025-06-23 18:31:16 +02:00
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
2e510b0862 Remove normalize_identifier benchmark
The benchmark is overly specific.
2025-06-20 16:19:24 +02:00
Corey Prophitt
26507e1173 Fixed typos in template syntax book docs 2025-06-20 10:17:06 +02:00
Guillaume Gomez
1275b58ccb
Merge pull request #486 from Kijewski/pr-more-core
Filters `linebreaks`, `paragraphbreaks` and `linebreaksbr` only need `core`
2025-06-17 16:54:01 +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
Guillaume Gomez
40bb5daab2
Merge pull request #489 from Kijewski/pr-no-memchr
parser: implement `{% raw %}` and `Lit::parse()` without `skip_till`
2025-06-17 11:13:06 +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
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