Skip to content

Commit

Permalink
Bugfix to avoid code injection when eval()
Browse files Browse the repository at this point in the history
  • Loading branch information
Liming Xie committed Apr 8, 2016
1 parent 9ca2934 commit 8bb3552
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions mixin.js
Expand Up @@ -157,6 +157,9 @@ function mixin(base, mixin) {
}

function mixin_constructor(name, ctor) {
// validate base name to avoid evil code injection
if(!/^[$A-Z_][0-9A-Z_$]*$/i.test(name)) return;

var str = "function __ctor() { var c = ctor.constructors; for (var i in c) { c[i].apply(this, arguments); } };".replace(/__ctor/g, name);
eval(str);
return eval(name);
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,7 +1,7 @@
{
"name": "mixin-pro",
"description": "Javascript multi-inheritance with mixin for code reuse",
"version": "0.6.6",
"version": "0.6.7",
"author": "Raymond Xie <rjfun.mobile@gmail.com>",
"repository": {
"type": "git",
Expand Down

0 comments on commit 8bb3552

Please sign in to comment.