YUKI Hiroshi
null+****@clear*****
Wed Nov 21 19:52:15 JST 2012
YUKI Hiroshi 2012-11-21 19:52:15 +0900 (Wed, 21 Nov 2012) New Revision: 7f1f0cf4bbc3cd7c29131629a3126a55a0adc957 https://github.com/groonga/gcs/commit/7f1f0cf4bbc3cd7c29131629a3126a55a0adc957 Log: Report error for invalid index of collections Modified files: lib/api/2011-02-01/configuration.js lib/errors.js Modified: lib/api/2011-02-01/configuration.js (+10 -2) =================================================================== --- lib/api/2011-02-01/configuration.js 2012-11-21 19:51:57 +0900 (d48c0eb) +++ lib/api/2011-02-01/configuration.js 2012-11-21 19:52:15 +0900 (3afcefe) @@ -202,7 +202,11 @@ function createDomainStatusList(options) { handlers.DescribeDomains = function(context, request, response, config) { var keys = Object.keys(request.query).filter(function(key) { - return /^DomainNames\.member\.\d+$/.test(key); + var match = key.match(/^DomainNames\.member\.([^\.]+)$/); + if (!match) return false; + if (!/^[1-9]/.test(match[1])) + throw new errors.MalformedInputError('Key ' + match[1] + ' may not have a leading \'' + match[1].charAt(0) + '\''); + return true; }); var domainNames = keys.sort().map(function(key) { return request.query[key]; @@ -423,7 +427,11 @@ handlers.DescribeIndexFields = function(context, request, response, config) { }); var keys = Object.keys(request.query).filter(function(key) { - return /^FieldNames\.member\.\d+$/.test(key); + var match = key.match(/^FieldNames\.member\.([^\.]+)$/); + if (!match) return false; + if (!/^[1-9]/.test(match[1])) + throw new errors.MalformedInputError('Key ' + match[1] + ' may not have a leading \'' + match[1].charAt(0) + '\''); + return true; }); var fieldNames = keys.sort().map(function(key) { return request.query[key]; Modified: lib/errors.js (+9 -2) =================================================================== --- lib/errors.js 2012-11-21 19:51:57 +0900 (83cf128) +++ lib/errors.js 2012-11-21 19:52:15 +0900 (d5be889) @@ -8,7 +8,6 @@ function ValidationError(message) { } exports.ValidationError = ValidationError; - function FieldOptionConflictError(message) { var error = new Error(message); error.isValidationError = true; @@ -19,7 +18,6 @@ function FieldOptionConflictError(message) { } exports.FieldOptionConflictError = FieldOptionConflictError; - function ResourceNotFoundError(message) { var error = new Error(message); error.isNotFoundError = true; @@ -29,3 +27,12 @@ function ResourceNotFoundError(message) { return error; } exports.ResourceNotFoundError = ResourceNotFoundError; + +function MalformedInputError(message) { + var error = new Error(message); + error.isSenderError = true; + error.code = 'MalformedInput'; + error.type = 'MalformedInputError'; + return error; +} +exports.MalformedInputError = MalformedInputError; -------------- next part -------------- HTML����������������������������... 下载