diff --git a/lib/compile/util.js b/lib/compile/util.js index ed5989f..fc7bfc4 100644 --- a/lib/compile/util.js +++ b/lib/compile/util.js @@ -7,7 +7,6 @@ module.exports = { checkDataTypes: checkDataTypes, toHash: toHash, getProperty: getProperty, - escapeQuotes: escapeQuotes, escapeRegExp: escapeRegExp, ucs2length: ucs2length, varOccurences: varOccurences, @@ -85,12 +84,7 @@ var IDENTIFIER = /^[a-z$_][a-z$_0-9]*$/i; function getProperty(key) { return IDENTIFIER.test(key) ? '.' + key - : "['" + key + "']"; -} - - -function escapeQuotes(str) { - return str.replace(/'/g, "\\'"); + : "['" + key.replace(/'/g, "\\'") + "']"; } diff --git a/lib/dot/dependencies.jst b/lib/dot/dependencies.jst index 93b0020..fff1e3c 100644 --- a/lib/dot/dependencies.jst +++ b/lib/dot/dependencies.jst @@ -41,7 +41,7 @@ var {{=$errs}} = errors; if ({{=$data}}['{{= $property }}'] !== undefined) { {{ $it.schema = $sch; - $it.schemaPath = $schemaPath + "['" + it.util.escapeQuotes($property) + "']"; + $it.schemaPath = $schemaPath + it.util.getProperty($property); }} {{= it.validate($it) }} diff --git a/lib/dot/properties.jst b/lib/dot/properties.jst index 010c7e9..e36829a 100644 --- a/lib/dot/properties.jst +++ b/lib/dot/properties.jst @@ -79,9 +79,9 @@ var valid{{=$it.level}} = true; {{? {{# def.nonEmptySchema:$sch}} }} {{ $it.schema = $sch; - $it.schemaPath = $schemaPath + "['" + it.util.escapeQuotes($propertyKey) + "']"; var $prop = it.util.getProperty($propertyKey) , $passData = $data + $prop; + $it.schemaPath = $schemaPath + $prop; $it.errorPath = (it.errorPath + ' + "' + $prop + '"').replace('" + "', ''); $it.dataPath = it.dataPath + $prop; }} diff --git a/lib/dotjs/dependencies.js b/lib/dotjs/dependencies.js index 9189009..e48c2d5 100644 --- a/lib/dotjs/dependencies.js +++ b/lib/dotjs/dependencies.js @@ -77,7 +77,7 @@ module.exports = function anonymous(it) { if (it.util.schemaHasRules($sch, it.RULES.all)) { out += ' valid' + ($it.level) + ' = true; if (' + ($data) + '[\'' + ($property) + '\'] !== undefined) { '; $it.schema = $sch; - $it.schemaPath = $schemaPath + "['" + it.util.escapeQuotes($property) + "']"; + $it.schemaPath = $schemaPath + it.util.getProperty($property); out += ' ' + (it.validate($it)) + ' } '; if ($breakOnError) { out += ' if (valid' + ($it.level) + ') { '; diff --git a/lib/dotjs/properties.js b/lib/dotjs/properties.js index a284b97..46ff800 100644 --- a/lib/dotjs/properties.js +++ b/lib/dotjs/properties.js @@ -94,9 +94,9 @@ module.exports = function anonymous(it) { var $sch = $schema[$propertyKey]; if (it.util.schemaHasRules($sch, it.RULES.all)) { $it.schema = $sch; - $it.schemaPath = $schemaPath + "['" + it.util.escapeQuotes($propertyKey) + "']"; var $prop = it.util.getProperty($propertyKey), $passData = $data + $prop; + $it.schemaPath = $schemaPath + $prop; $it.errorPath = (it.errorPath + ' + "' + $prop + '"').replace('" + "', ''); $it.dataPath = it.dataPath + $prop; var $code = it.validate($it); diff --git a/package.json b/package.json index 7ad7e97..d733351 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ajv", - "version": "0.5.11", + "version": "0.5.12", "description": "Another JSON Schema Validator", "main": "lib/ajv.js", "scripts": {