Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] [Formatter] Djlint got stuck on my template #340

Closed
3 tasks done
PetrDlouhy opened this issue Aug 20, 2022 · 5 comments
Closed
3 tasks done

[BUG] [Formatter] Djlint got stuck on my template #340

PetrDlouhy opened this issue Aug 20, 2022 · 5 comments

Comments

@PetrDlouhy
Copy link

PetrDlouhy commented Aug 20, 2022

System Info

  • OS: ubuntu Linux 5.15.0-39-generic # 42-Ubuntu SMP Thu Jun 9 23:42:32 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
  • Python Version: Python 3.10.4
  • djLint Version: djlint, version 1.11.0
  • template language: django html template

Issue

Djlint got stuck when formating my template. All other templates are formated quickly, but this one takes forever (not finished after more than 10 minutes).

How To Reproduce

Run djlint --check plan_table.html --profile=django on attached template (I renamed it from html to txt in order to fit here).

plan_table.txt

@PetrDlouhy PetrDlouhy added 🔍 linter 🦠 bug Something isn't working labels Aug 20, 2022
@PetrDlouhy
Copy link
Author

I tried to make minimal example of file with the problems. I was able to reduce it to the attached file, where djlint runs for ~30 seconds (which is very long considering how simple the file is). When I delete some of the parameters of the first <div> it gets faster.
plan_table.txt

@christopherpickering
Copy link
Contributor

It looks like this is producing Catastrophic backtracking has been detected and the execution of your expression has been halted. To find out more and what this is, please read the following article: [Runaway Regular Expressions](http://www.regular-expressions.info/catastrophic.html) on expand.py:should_i_move_template_tag on the findall. I'll see if there is a way to fix it.

@christopherpickering christopherpickering changed the title [BUG] [Linter] Djlint got stuck on my template [BUG] [Formater] Djlint got stuck on my template Aug 22, 2022
@christopherpickering christopherpickering changed the title [BUG] [Formater] Djlint got stuck on my template [BUG] [Formatter] Djlint got stuck on my template Aug 22, 2022
christopherpickering pushed a commit that referenced this issue Aug 22, 2022
## [1.11.1](v1.11.0...v1.11.1) (2022-08-22)

### Bug Fixes

* **formatter:** fixed runaway regex on templates with many template attriutes inside html tags ([79cd013](79cd013)), closes [#340](#340)
* **linter:** fixed false positive on T032 with jinja multi line set ([f9dac86](f9dac86)), closes [#342](#342)
* **linter:** fixed false postive on rule H008 ([79618a5](79618a5)), closes [#339](#339)
* **linter:** prevent linter matches that overlap ignored blocks of code such as comments ([90cf576](90cf576)), closes [#343](#343)
@christopherpickering
Copy link
Contributor

🎉 This issue has been resolved in version 1.11.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@PetrDlouhy
Copy link
Author

@christopherpickering Thank you very much for your work, now it work nicely 👍

@christopherpickering
Copy link
Contributor

Cool, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants