minify-dead-code-elimination cause regexp match infinite loop.
See original GitHub issueDescribe the bug
To Reproduce
Minimal code to reproduce the bug
function getElementTransforms(el) {
if (!is.dom(el)) return;
const str = el.style.transform || '';
const reg = /(\w+)\(([^)]*)\)/g;
const transforms = new Map();
let m; while (m = reg.exec(str)) transforms.set(m[1], m[2]);
return transforms;
}
Actual Output
If there is no Error thrown,
function getElementTransforms(el) {
if (!is.dom(el)) return;
var str = el.style.transform || '';
var transforms = new Map();
var m;
while (m = /(\w+)\(([^)]*)\)/g.exec(str)) {
transforms.set(m[1], m[2]);
}
return transforms;
}
Expected Output
function getElementTransforms(el) {
if (!is.dom(el)) return;
var str = el.style.transform || '';
var reg = /(\w+)\(([^)]*)\)/g;
var transforms = new Map();
var m;
while (m = reg.exec(str)) {
transforms.set(m[1], m[2]);
}
return transforms;
}
Configuration Can be reproduce Using Babel’s Online Try Out
babel-minify CLI
babel-plugin-minify-dead-code-elimination: 0.5.1
babel version : 7.9.0
babel-minify-config: default without config
Issue Analytics
- State:
- Created 3 years ago
- Reactions:5
- Comments:8 (1 by maintainers)
Top Results From Across the Web
babel-plugin-minify-dead-code-elimination-while-loop-fixed
Inlines bindings when possible. Tries to evaluate expressions and prunes unreachable as a result.
Read more >regular expression goes into infinite loop - Stack Overflow
Essentially, what is happening is there are too many ways to match your regular expression with your string, and the parser is continually...
Read more >Changelog — Python 3.11.1 documentation
These cases now raise ValueError - Removed a dead code path ... gh-98458: Fix infinite loop in unittest when a self-referencing chained exception...
Read more >rollup.js
Rollup is a module bundler for JavaScript which compiles small pieces of code into something larger and more complex, such as a library...
Read more >https://perldoc.perl.org/5.22.0/perldelta.txt
This could lead to different outcomes than existing code expects (though the documentation ... PATTERN?> construct, which allows matching a regex only once, ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It seems strange to me that babel-plugin-minify-dead-code-elimination is even doing anything here - after all, the code isn’t dead.
Replacing named constants that are only used in one place seems like a reasonable thing to do in general, but I would expect a different plugin to be responsible for it.
Same here!