tree-sitter / tree-sitter-html

HTML grammar for Tree-sitter
MIT License
136 stars 72 forks source link

Custom tags longer than 10 characters cause an error in WASM #30

Closed gushogg-blake closed 1 year ago

gushogg-blake commented 3 years ago

Custom tag names cause an error if the name is longer than 10 chars, e.g. <foobar1234/> is fine but <foobar12345/> throws an error.

I've just been looking through the source and noticed that 10 chars is the longest tag name listed in https://github.com/tree-sitter/tree-sitter-html/blob/master/src/tag.h - could this be related somehow or just coincidence?

Here's the error:

Uncaught (in promise) TypeError: Cannot read property 'apply' of undefined
    at e.<computed> (tree-sitter.js:1)
    at _ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEC2ERKS5_ (<anonymous>:wasm-function[156]:0xae62)
    at _ZN3TagC2E7TagTypeRKNSt3__212basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE (<anonymous>:wasm-function[140]:0xac7a)
    at _ZN3Tag8for_nameERKNSt3__212basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEE (<anonymous>:wasm-function[124]:0xa9e7)
    at tree_sitter_html_external_scanner_scan (<anonymous>:wasm-function[25]:0x9cb9)
    at ts_parser_parse_wasm (tree-sitter.wasm:0x196e4)
    at Parser.parse (tree-sitter.js:1)

Cheers!

Gus

rich770 commented 2 years ago

I can confirm this issue, and it can be tested on the Tree-sitter "play-ground" page, when set to HTML. This works: <xml-test12></xml-text12> This makes it fail: <xml-test123></xml-text123>

The fail does not make a soft error, as if you wrote something wrong, but instead it crashes.
The error message can also be seen in the console on the "play-ground" page with dev tools, since that also uses the WASM files.
It seems the input length is hardcoded somewhere.

amaanq commented 1 year ago

cannot replicate the first one - maybe it's a wasm issue

for the second, text != test

pokey commented 11 months ago

for people arriving at this issue because they're having errors parsing xml using this tree-sitter, you likely want to switch to https://github.com/ObserverOfTime/tree-sitter-xml for parsing xml