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

Invalid <script> tag content with minify_js=True hangs #199

Open
laurentgoudet opened this issue Jul 29, 2024 · 1 comment
Open

Invalid <script> tag content with minify_js=True hangs #199

laurentgoudet opened this issue Jul 29, 2024 · 1 comment

Comments

@laurentgoudet
Copy link

  • Install Python 3.11 & latest version of minify-html (0.15.0)
$ pyenv install 3.11.9
$ pyenv local 3.11.9
$ pip install minify-html
  • Try to minify an invalid <script> tag, with minify_js=True
$ python -c 'from minify_html import minify; minify("<script><br></script>", minify_js=True)'
  • Python process hangs

  • Running strace shows:

Working version (without the <br> tag):
works.txt

Broken (with the <br> tag):
broken.txt

i.e. instead of calling write(1, "<script></script>\n", 18<script></script> to output the content to stdout it calls getrandom() and then hangs after an nmap.

This is reproducible with latest Python (3.12.4) as well.

@laurentgoudet
Copy link
Author

laurentgoudet commented Jul 29, 2024

Not sure if this should have been reported to https://github.com/wilsonzlin/minify-js actually, but FWIW if I try to minify <br> (in src.js) minify-js exits (with 101):

RUST_BACKTRACE=full ./minify-js -m global src.js
thread 'main' panicked at cli/src/main.rs:38:52:
minify: UnexpectedEnd [token=Some(EOF)] around ``````
stack backtrace:
   0:        0x100d786d0 - __mh_execute_header
   1:        0x100cf9e7b - __mh_execute_header
   2:        0x100d51e2e - __mh_execute_header
   3:        0x100d7c743 - __mh_execute_header
   4:        0x100d7c4e1 - __mh_execute_header
   5:        0x100d7ccef - __mh_execute_header
   6:        0x100d7c8ee - __mh_execute_header
   7:        0x100d7c849 - __mh_execute_header
   8:        0x100d7c832 - __mh_execute_header
   9:        0x100d84c05 - __mh_execute_header
  10:        0x100d85115 - __mh_execute_header
  11:        0x100ca8fe2 - __mh_execute_header
  12:        0x100ca5016 - __mh_execute_header
  13:        0x100caa286 - __mh_execute_header

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

No branches or pull requests

1 participant