Since version 2.20.8 I got error "panic: runtime error: index out of range [nnn] with length nnn"
ebta opened this issue · comments
Ebta Setiawan commented
Since version 2.20.8 (2.20.9 included), I got error like this if running minify on php files
panic: runtime error: index out of range [8295] with length 8295
goroutine 22 [running]:
github.com/tdewolff/parse/v2.(*Input).Peek(...)
github.com/tdewolff/parse/v2@v2.7.6/input.go:105
github.com/tdewolff/parse/v2/html.(*Lexer).Next(0xc000126090)
github.com/tdewolff/parse/v2@v2.7.6/html/lex.go:163 +0x49e
github.com/tdewolff/minify/v2/html.(*TokenBuffer).read(0xc000147670, 0xc0000e2a80)
github.com/tdewolff/minify/v2/html/buffer.go:42 +0x33
github.com/tdewolff/minify/v2/html.(*TokenBuffer).Shift(0x603760?)
github.com/tdewolff/minify/v2/html/buffer.go:104 +0x30
github.com/tdewolff/minify/v2/html.(*Minifier).Minify(0xc0000890b0, 0xc00009e3c0, {0x603740, 0xc000089110}, {0x603760, 0xc000089140}, 0x0?)
github.com/tdewolff/minify/v2/html/html.go:85 +0x345
github.com/tdewolff/minify/v2.(*M).MinifyMimetype(0xc00009e3c0, {0xc0000b0678, 0x17, 0x18}, {0x603740, 0xc000089110}, {0x603760, 0xc000089140}, 0x5551c0?)
github.com/tdewolff/minify/v2/minify.go:210 +0x167
github.com/tdewolff/minify/v2.(*M).Minify(0x603a00?, {0x57f6e0?, 0xc00009a3e0?}, {0x603740, 0xc000089110}, {0x603760, 0xc000089140})
github.com/tdewolff/minify/v2/minify.go:199 +0x78
main.minify({{0x601248, 0x1}, {0xc00008a250, 0x1, 0x1}, {0xc00009a3e0, 0x1d}, 0x0})
github.com/tdewolff/minify/v2/cmd/minify/main.go:885 +0xdbd
main.minifyWorker(0x0?, 0x0?)
github.com/tdewolff/minify/v2/cmd/minify/main.go:602 +0xff
created by main.run in goroutine 1
github.com/tdewolff/minify/v2/cmd/minify/main.go:525 +0x3565
This is not happen in version 2.20.7 (file type php is supported yet in this version)
Taco de Wolff commented
Thanks for raising this issue. Could you please send me the file (or a part thereof) that causes this issue?
Ebta Setiawan commented
this is just simple example php file: sample.php
Using command
minify -v sample.php -o sample-out.php
will raise runtime error
Taco de Wolff commented
This has been fixed in v2.20.10!