| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
Well, it's not problem of Jinja itself: we can pass undefined=StrictUndefined and it will die on any use of an undefined variable. But it would probably mean fixing half of the templates :( Also, do we really need to pass everything through a macro? Wouldn't it be easier to pack all fields in an object and pass the object instead? (But no, I am not volunteering to rewrite the whole template now :)) |
Sorry, something went wrong.
we already use undefined=StrictUndefined. the problem here is that the buggy code isn't ever being evaluated (the problematic or is short-circuiting and the bad case never came up in any tests). the solution to this is static type-checking, but there is no type checker that can parse jinja templates.
idk about that solution, but there's another way to avoid passing all those arguments, and that's to not use macros. cms actually used to do this, but it was changed to the macro (#1115) because it "is supposedly safer (as they don't rely on state of the context, which is error prone)." I disagree with that justification, as that was literally the commit that introduced this bug. |
Sorry, something went wrong.
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## main #1550 +/- ##
==========================================
- Coverage 54.72% 54.71% -0.01%
==========================================
Files 336 336
Lines 27469 27469
==========================================
- Hits 15032 15030 -2
- Misses 12437 12439 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry.
|
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Fixes #1548.
I really hate this feature of jinja (both the fact that we need to thread all variables through macro arguments manually, and the fact that this obvious use-of-undefined-variable isn't caught automatically) but i don't know how to avoid it, short of rewriting CMS in rust or something.