|
@@ -1,7 +1,8 @@
|
|
|
-var utils = require('./utils'),
|
|
|
|
|
- stringSaveRE = /"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'/g,
|
|
|
|
|
|
|
+var utils = require('./utils'),
|
|
|
|
|
+ stringSaveRE = /"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'/g,
|
|
|
stringRestoreRE = /"(\d+)"/g,
|
|
stringRestoreRE = /"(\d+)"/g,
|
|
|
- constructorRE = /(^|\.)constructor\(/
|
|
|
|
|
|
|
+ constructorRE = new RegExp('constructor'.split('').join('[\'"+, ]*')),
|
|
|
|
|
+ unicodeRE = /\\u\d\d\d\d/
|
|
|
|
|
|
|
|
// Variable extraction scooped from https://github.com/RubyLouvre/avalon
|
|
// Variable extraction scooped from https://github.com/RubyLouvre/avalon
|
|
|
|
|
|
|
@@ -110,7 +111,8 @@ module.exports = {
|
|
|
* created as bindings.
|
|
* created as bindings.
|
|
|
*/
|
|
*/
|
|
|
parse: function (exp, compiler) {
|
|
parse: function (exp, compiler) {
|
|
|
- if (constructorRE.test(exp)) {
|
|
|
|
|
|
|
+ // unicode and 'constructor' are not allowed for XSS security.
|
|
|
|
|
+ if (unicodeRE.test(exp) || constructorRE.test(exp)) {
|
|
|
utils.warn('Unsafe expression: ' + exp)
|
|
utils.warn('Unsafe expression: ' + exp)
|
|
|
return function () {}
|
|
return function () {}
|
|
|
}
|
|
}
|