Treat caller() as variable with support for aliasing#510
Treat caller() as variable with support for aliasing#510GuillaumeGomez merged 5 commits intoaskama-rs:masterfrom
Conversation
7dad9af to
033dfe6
Compare
|
I hope I got everything. I now explicitly generate a |
8f11902 to
9acc389
Compare
|
Whoops, forgot to change the |
|
Should I bump the cargo version in github workflows as part of this PR, or separately? |
|
You also need to update the version used in CI. |
9acc389 to
a1ec7d2
Compare
a1ec7d2 to
da96be4
Compare
|
Is the Cluster-Fuzz error something I have to fix? |
|
Seems it's on the fuzzer side that something needs to be updated. Let's wait for @Kijewski to take a look at your PR first, we can check for the fuzzer afterwards. |
|
We need to update our config like for the update to 1.83: google/oss-fuzz#13237. I can have a look at the PR later today. I'm not very well versed in that part of our codebase, though, so I'll mostly have to trust the unit tests. :) @GuillaumeGomez, do you want to file a PR @ oss-fuzz? Otherwise I can do it this evening. |
|
Sure! |
|
I think there already is one: google/oss-fuzz#13198 |
|
We override the version, that gives us more liberty. Ie: if we need to update the rust version used, we won't impact other projects. Simpler for everyone. :) |
|
So just waiting for the oss-fuzz to be merged then we can restart CI here and merge. :) |
da96be4 to
d50cb4f
Compare
The next version of askama (v0.15) will need at least rust 1.88 to compile. The current toolchain shipped in docker (for askama) is rust 1.83, so the project could not get fuzzed anymore. This PR sets the used toolchain to 1.88. Cc @Kijewski Related PR: askama-rs/askama#510
|
Fuzzer passed, so merging time. Thanks! |
While implementing #505 over my previous version of fixing #507 (#509), I noticed that there is a much better way which actually fixes both at the same time.
The
localMapChainnow keeps track of:calleror another alias) - this contains the call-site definition, as well as the call site'sContext<'a>as metadataBasic design:
When a
{% call ... %}block is entered, I pushcalleras aLocalMeta::CallerAliasinto thelocalmap, together with the call-siteContext<'a>andCall<'a>definition.When a variable is assigned from another variable (
Expr::Var(dst) = Expr::Var(src)), where thesrcvariable is alocalof typeLocalMeta::CallerAlias, the variabledstwill also be inserted as caller alias by simply cloningsrc.When a call expression like
{{ abc() }}is encountered, whose variable is aLocalMeta::CallerAlias, we have found a{{ caller() }}, or any kind of:{{ caller_alias() }}. As soon as a newlocalscope was created for the call intocaller(), aLocalMeta::Negativeis inserted into the LocalMap. With this, thecallervariable is blocked from access for this scope, and any number of scopes above - until a new entry forcalleris inserted in one of the upper scopes. This prohibits callers from calling themselves - which is not supported. This was previously handled by trackingactive_caller- but that was not prepared for multiple layers. Due to this restructuring, the error message changed a bit - but I like the new one better.Imho, this design is rather elegant, since it also "accidentally" is the perfect preparation for supporting the short call syntax of jinja that askama is currently missing:
Fixes #505.
Fixes #507.