Skip to content

Commit 037c2d0

Browse files
[Refactor] Harden against pathological function names
Change the regular expression for matching the function name to avoid potential quadratic runtime of the implementation of `Function.prototype.name` due to the regular expression in `es6-sham.js:157`. I'm not aware of any input that would trigger such behavior, however the fix in this case is trivial. In fact, both the leading `\s` and trailing `\s` in the regular expression are unnecessary (though, based on context, I would say the leading `\s` is actually necessary, however it currently isn't so...).
1 parent 0265dc4 commit 037c2d0

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

es6-sham.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@
154154
return '';
155155
}
156156
var str = _call(functionToString, this);
157-
var match = _call(_strMatch, str, /\s*function\s+([^(\s]*)\s*/);
157+
var match = _call(_strMatch, str, /\s?function\s+([^(\s]*)\s*/);
158158
var name = match && match[1];
159159
Object.defineProperty(this, 'name', {
160160
configurable: true,

es6-sham.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)