This commit is contained in:
mcardosos 2018-04-23 17:55:55 -07:00
Родитель 237bc2756e
Коммит 8ce102730d
3 изменённых файлов: 8 добавлений и 8 удалений

Просмотреть файл

@ -577,11 +577,11 @@ module.exports.validateContentType = function (contentType, supportedTypes, resu
module.exports.constructSchemaPathFromPtr = function (ptr, schema) {
var refs = JsonRefs.pathFromPtr(ptr)
var paths = []
var paths = [];
refs.forEach(function (element) {
element = escapeSingleQuotes(element)
paths.push(element)
element = escapeSingleQuotes(element);
paths.push(element);
});
var schemaPath = "['" + paths.join("']['") + "']";
@ -631,5 +631,5 @@ var walk = module.exports.walk = function (obj, fn) {
* @returns {string} - The already escaped string
*/
var escapeSingleQuotes = module.exports.escapeSingleQuotes = function (value) {
return value.split("'").join('%27')
return value.split("'").join('%27');
}

Просмотреть файл

@ -126,7 +126,7 @@ function ParameterValue (parameterObject, raw) {
if (!skipValidation) {
// Validate against JSON Schema
schemaObj = parameterObject.pathObject.api.definition;
schemaObj = escapePaths(schemaObj)
schemaObj = escapePaths(schemaObj);
schemaPath = helpers.constructSchemaPathFromPtr(parameterObject.ptr, parameterObject.definition.schema);
result = helpers.validateAgainstSchema(helpers.getJSONSchemaValidator(), schemaObj, value, schemaPath);
}
@ -229,7 +229,7 @@ function escapePaths (schema) {
_.each(schema['paths'], function (value, key) {
schema['paths'][helpers.escapeSingleQuotes(key)] = value;
})
return schema
return schema;
}
module.exports = ParameterValue;

Просмотреть файл

@ -175,8 +175,8 @@ Parameter.prototype.getValue = function (req) {
if (_.isUndefined(req.originalUrl) && _.isUndefined(req.url)) {
throw new Error('req.originalUrl or req.url must be provided for \'path\' parameters');
}
urlObj.pathname = decodeURIComponent(urlObj.pathname)
urlObj.path = decodeURIComponent(urlObj.path)
urlObj.pathname = decodeURIComponent(urlObj.pathname);
urlObj.path = decodeURIComponent(urlObj.path);
if (this.pathObject.hostTemplate) {
// hostname needs to be a part of the data for doing the regex match while processing
// x-ms-parameterized-host extension.