formulahendry/vscode-auto-close-tag

Catastrophic backtracking of regexp match in getCloseTag

Offen

#41 geöffnet am 15.05.2017

 (3 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)TypeScript (52 Forks)github user discovery
bughelp wanted

Repository-Metriken

Stars
 (180 Sterne)
PR-Merge-Metriken
 (PR-Metriken ausstehend)

Beschreibung

Invoking auto close tag after lengthy tag (say, SVG <shape d="(lots of data)" />) either void/self-closing (<.../>) or with white-space before > hangs the extension:

<x 
0 1 2 3 4 5 6 7 8 9
0 1 2 3 4 5 6 7 8 9
0 1 2 3 4 5 6 7 8 9
0 1 2 3 4 5 6 7 8 9
0 1 2 3 4 5 6 7 8 9
0 1 2 3 4 5 6 7 8 9
0 1 2 3 4 5 6 7 8 9
0 1 2 3 4 5 6 7 8 9
0 1 2 3 4 5 6 7 8 9/>
<y>|

(try https://regex101.com/r/CZBpI4/1 )

I'd try to change the regexp at [1] from /<(\/?[a-zA-Z][a-zA-Z0-9:\-_.]*)(?:\s+[^<>]*?[^\s/<>=]+?)*?>/g (BTW, why such complicated?) to say <((\/?)[a-zA-Z][a-zA-Z0-9:\-_.]*)\s*[^>]*?(\/?)> to prevent that (just guess, haven't tested myself yet in VSC).

Sorry for hurried report; just burnt evening tracking this with no time left for fixup.

[1] https://github.com/formulahendry/vscode-auto-close-tag/blob/ee36d506641990632bf79326f2adc4fc69efa288/src/extension.ts#L135


What seems scary is that hung extension host survives restart of VS Code and continues eating CPU as a zombie process. Is it normal?

Contributor Guide