mirror of https://github.com/pelias/api.git
Stephen K Hess
8 years ago
committed by
GitHub
56 changed files with 262 additions and 262 deletions
@ -1,34 +0,0 @@ |
|||||||
var type_mapping = require('../helper/type_mapping'); |
|
||||||
|
|
||||||
var sanitizeAll = require('../sanitiser/sanitizeAll'), |
|
||||||
sanitizers = { |
|
||||||
singleScalarParameters: require('../sanitiser/_single_scalar_parameters'), |
|
||||||
text: require('../sanitiser/_text_addressit'), |
|
||||||
tokenizer: require('../sanitiser/_tokenizer'), |
|
||||||
size: require('../sanitiser/_size')(10, 10, 10), |
|
||||||
layers: require('../sanitiser/_targets')('layers', type_mapping.layer_mapping), |
|
||||||
sources: require('../sanitiser/_targets')('sources', type_mapping.source_mapping), |
|
||||||
// depends on the layers and sources sanitisers, must be run after them
|
|
||||||
sources_and_layers: require('../sanitiser/_sources_and_layers'), |
|
||||||
private: require('../sanitiser/_flag_bool')('private', false), |
|
||||||
geo_autocomplete: require('../sanitiser/_geo_autocomplete'), |
|
||||||
boundary_country: require('../sanitiser/_boundary_country'), |
|
||||||
categories: require('../sanitiser/_categories') |
|
||||||
}; |
|
||||||
|
|
||||||
var sanitize = function(req, cb) { sanitizeAll(req, sanitizers, cb); }; |
|
||||||
|
|
||||||
// export sanitize for testing
|
|
||||||
module.exports.sanitize = sanitize; |
|
||||||
module.exports.sanitiser_list = sanitizers; |
|
||||||
|
|
||||||
// middleware
|
|
||||||
module.exports.middleware = function( req, res, next ){ |
|
||||||
sanitize( req, function( err, clean ){ |
|
||||||
if( err ){ |
|
||||||
res.status(400); // 400 Bad Request
|
|
||||||
return next(err); |
|
||||||
} |
|
||||||
next(); |
|
||||||
}); |
|
||||||
}; |
|
@ -1,28 +0,0 @@ |
|||||||
|
|
||||||
var type_mapping = require('../helper/type_mapping'); |
|
||||||
var sanitizeAll = require('../sanitiser/sanitizeAll'), |
|
||||||
sanitizers = { |
|
||||||
quattroshapes_deprecation: require('../sanitiser/_deprecate_quattroshapes'), |
|
||||||
singleScalarParameters: require('../sanitiser/_single_scalar_parameters'), |
|
||||||
layers: require('../sanitiser/_targets')('layers', type_mapping.layer_mapping), |
|
||||||
sources: require('../sanitiser/_targets')('sources', type_mapping.source_mapping), |
|
||||||
// depends on the layers and sources sanitisers, must be run after them
|
|
||||||
sources_and_layers: require('../sanitiser/_sources_and_layers'), |
|
||||||
size: require('../sanitiser/_size')(/* use defaults*/), |
|
||||||
private: require('../sanitiser/_flag_bool')('private', false), |
|
||||||
geo_reverse: require('../sanitiser/_geo_reverse'), |
|
||||||
boundary_country: require('../sanitiser/_boundary_country') |
|
||||||
}; |
|
||||||
|
|
||||||
var sanitize = function(req, cb) { sanitizeAll(req, sanitizers, cb); }; |
|
||||||
|
|
||||||
// export sanitize for testing
|
|
||||||
module.exports.sanitize = sanitize; |
|
||||||
module.exports.sanitiser_list = sanitizers; |
|
||||||
|
|
||||||
// middleware
|
|
||||||
module.exports.middleware = function( req, res, next ){ |
|
||||||
sanitize( req, function( err, clean ){ |
|
||||||
next(); |
|
||||||
}); |
|
||||||
}; |
|
@ -1,26 +0,0 @@ |
|||||||
var type_mapping = require('../helper/type_mapping'); |
|
||||||
|
|
||||||
var sanitizeAll = require('../sanitiser/sanitizeAll'), |
|
||||||
sanitizers = { |
|
||||||
quattroshapes_deprecation: require('../sanitiser/_deprecate_quattroshapes'), |
|
||||||
singleScalarParameters: require('../sanitiser/_single_scalar_parameters'), |
|
||||||
text: require('../sanitiser/_text'), |
|
||||||
size: require('../sanitiser/_size')(/* use defaults*/), |
|
||||||
layers: require('../sanitiser/_targets')('layers', type_mapping.layer_mapping), |
|
||||||
sources: require('../sanitiser/_targets')('sources', type_mapping.source_mapping), |
|
||||||
// depends on the layers and sources sanitisers, must be run after them
|
|
||||||
sources_and_layers: require('../sanitiser/_sources_and_layers'), |
|
||||||
private: require('../sanitiser/_flag_bool')('private', false), |
|
||||||
geo_search: require('../sanitiser/_geo_search'), |
|
||||||
boundary_country: require('../sanitiser/_boundary_country'), |
|
||||||
categories: require('../sanitiser/_categories') |
|
||||||
}; |
|
||||||
|
|
||||||
var sanitize = function(req, cb) { sanitizeAll(req, sanitizers, cb); }; |
|
||||||
|
|
||||||
// middleware
|
|
||||||
module.exports.middleware = function( req, res, next ){ |
|
||||||
sanitize( req, function( err, clean ){ |
|
||||||
next(); |
|
||||||
}); |
|
||||||
}; |
|
@ -1,5 +1,5 @@ |
|||||||
/** |
/** |
||||||
* helper sanitiser methods for geo parameters |
* helper sanitizer methods for geo parameters |
||||||
*/ |
*/ |
||||||
var groups = require('./_groups'), |
var groups = require('./_groups'), |
||||||
util = require('util'), |
util = require('util'), |
@ -0,0 +1,34 @@ |
|||||||
|
var type_mapping = require('../helper/type_mapping'); |
||||||
|
|
||||||
|
var sanitizeAll = require('../sanitizer/sanitizeAll'), |
||||||
|
sanitizers = { |
||||||
|
singleScalarParameters: require('../sanitizer/_single_scalar_parameters'), |
||||||
|
text: require('../sanitizer/_text_addressit'), |
||||||
|
tokenizer: require('../sanitizer/_tokenizer'), |
||||||
|
size: require('../sanitizer/_size')(10, 10, 10), |
||||||
|
layers: require('../sanitizer/_targets')('layers', type_mapping.layer_mapping), |
||||||
|
sources: require('../sanitizer/_targets')('sources', type_mapping.source_mapping), |
||||||
|
// depends on the layers and sources sanitizers, must be run after them
|
||||||
|
sources_and_layers: require('../sanitizer/_sources_and_layers'), |
||||||
|
private: require('../sanitizer/_flag_bool')('private', false), |
||||||
|
geo_autocomplete: require('../sanitizer/_geo_autocomplete'), |
||||||
|
boundary_country: require('../sanitizer/_boundary_country'), |
||||||
|
categories: require('../sanitizer/_categories') |
||||||
|
}; |
||||||
|
|
||||||
|
var sanitize = function(req, cb) { sanitizeAll(req, sanitizers, cb); }; |
||||||
|
|
||||||
|
// export sanitize for testing
|
||||||
|
module.exports.sanitize = sanitize; |
||||||
|
module.exports.sanitizer_list = sanitizers; |
||||||
|
|
||||||
|
// middleware
|
||||||
|
module.exports.middleware = function( req, res, next ){ |
||||||
|
sanitize( req, function( err, clean ){ |
||||||
|
if( err ){ |
||||||
|
res.status(400); // 400 Bad Request
|
||||||
|
return next(err); |
||||||
|
} |
||||||
|
next(); |
||||||
|
}); |
||||||
|
}; |
@ -1,17 +1,17 @@ |
|||||||
var _ = require('lodash'); |
var _ = require('lodash'); |
||||||
var sanitizeAll = require('../sanitiser/sanitizeAll'); |
var sanitizeAll = require('../sanitizer/sanitizeAll'); |
||||||
var reverseSanitizers = require('./reverse').sanitiser_list; |
var reverseSanitizers = require('./reverse').sanitizer_list; |
||||||
|
|
||||||
// add categories to the sanitizer list
|
// add categories to the sanitizer list
|
||||||
var sanitizers = _.merge({}, reverseSanitizers, { |
var sanitizers = _.merge({}, reverseSanitizers, { |
||||||
categories: require('../sanitiser/_categories') |
categories: require('../sanitizer/_categories') |
||||||
}); |
}); |
||||||
|
|
||||||
var sanitize = function(req, cb) { sanitizeAll(req, sanitizers, cb); }; |
var sanitize = function(req, cb) { sanitizeAll(req, sanitizers, cb); }; |
||||||
|
|
||||||
// export sanitize for testing
|
// export sanitize for testing
|
||||||
module.exports.sanitize = sanitize; |
module.exports.sanitize = sanitize; |
||||||
module.exports.sanitiser_list = sanitizers; |
module.exports.sanitizer_list = sanitizers; |
||||||
|
|
||||||
// middleware
|
// middleware
|
||||||
module.exports.middleware = function( req, res, next ){ |
module.exports.middleware = function( req, res, next ){ |
@ -1,16 +1,16 @@ |
|||||||
|
|
||||||
var sanitizeAll = require('../sanitiser/sanitizeAll'), |
var sanitizeAll = require('../sanitizer/sanitizeAll'), |
||||||
sanitizers = { |
sanitizers = { |
||||||
singleScalarParameters: require('../sanitiser/_single_scalar_parameters'), |
singleScalarParameters: require('../sanitizer/_single_scalar_parameters'), |
||||||
ids: require('../sanitiser/_ids'), |
ids: require('../sanitizer/_ids'), |
||||||
private: require('../sanitiser/_flag_bool')('private', false) |
private: require('../sanitizer/_flag_bool')('private', false) |
||||||
}; |
}; |
||||||
|
|
||||||
var sanitize = function(req, cb) { sanitizeAll(req, sanitizers, cb); }; |
var sanitize = function(req, cb) { sanitizeAll(req, sanitizers, cb); }; |
||||||
|
|
||||||
// export sanitize for testing
|
// export sanitize for testing
|
||||||
module.exports.sanitize = sanitize; |
module.exports.sanitize = sanitize; |
||||||
module.exports.sanitiser_list = sanitizers; |
module.exports.sanitizer_list = sanitizers; |
||||||
|
|
||||||
// middleware
|
// middleware
|
||||||
module.exports.middleware = function( req, res, next ){ |
module.exports.middleware = function( req, res, next ){ |
@ -0,0 +1,28 @@ |
|||||||
|
|
||||||
|
var type_mapping = require('../helper/type_mapping'); |
||||||
|
var sanitizeAll = require('../sanitizer/sanitizeAll'), |
||||||
|
sanitizers = { |
||||||
|
quattroshapes_deprecation: require('../sanitizer/_deprecate_quattroshapes'), |
||||||
|
singleScalarParameters: require('../sanitizer/_single_scalar_parameters'), |
||||||
|
layers: require('../sanitizer/_targets')('layers', type_mapping.layer_mapping), |
||||||
|
sources: require('../sanitizer/_targets')('sources', type_mapping.source_mapping), |
||||||
|
// depends on the layers and sources sanitizers, must be run after them
|
||||||
|
sources_and_layers: require('../sanitizer/_sources_and_layers'), |
||||||
|
size: require('../sanitizer/_size')(/* use defaults*/), |
||||||
|
private: require('../sanitizer/_flag_bool')('private', false), |
||||||
|
geo_reverse: require('../sanitizer/_geo_reverse'), |
||||||
|
boundary_country: require('../sanitizer/_boundary_country') |
||||||
|
}; |
||||||
|
|
||||||
|
var sanitize = function(req, cb) { sanitizeAll(req, sanitizers, cb); }; |
||||||
|
|
||||||
|
// export sanitize for testing
|
||||||
|
module.exports.sanitize = sanitize; |
||||||
|
module.exports.sanitizer_list = sanitizers; |
||||||
|
|
||||||
|
// middleware
|
||||||
|
module.exports.middleware = function( req, res, next ){ |
||||||
|
sanitize( req, function( err, clean ){ |
||||||
|
next(); |
||||||
|
}); |
||||||
|
}; |
@ -0,0 +1,26 @@ |
|||||||
|
var type_mapping = require('../helper/type_mapping'); |
||||||
|
|
||||||
|
var sanitizeAll = require('../sanitizer/sanitizeAll'), |
||||||
|
sanitizers = { |
||||||
|
quattroshapes_deprecation: require('../sanitizer/_deprecate_quattroshapes'), |
||||||
|
singleScalarParameters: require('../sanitizer/_single_scalar_parameters'), |
||||||
|
text: require('../sanitizer/_text'), |
||||||
|
size: require('../sanitizer/_size')(/* use defaults*/), |
||||||
|
layers: require('../sanitizer/_targets')('layers', type_mapping.layer_mapping), |
||||||
|
sources: require('../sanitizer/_targets')('sources', type_mapping.source_mapping), |
||||||
|
// depends on the layers and sources sanitizers, must be run after them
|
||||||
|
sources_and_layers: require('../sanitizer/_sources_and_layers'), |
||||||
|
private: require('../sanitizer/_flag_bool')('private', false), |
||||||
|
geo_search: require('../sanitizer/_geo_search'), |
||||||
|
boundary_country: require('../sanitizer/_boundary_country'), |
||||||
|
categories: require('../sanitizer/_categories') |
||||||
|
}; |
||||||
|
|
||||||
|
var sanitize = function(req, cb) { sanitizeAll(req, sanitizers, cb); }; |
||||||
|
|
||||||
|
// middleware
|
||||||
|
module.exports.middleware = function( req, res, next ){ |
||||||
|
sanitize( req, function( err, clean ){ |
||||||
|
next(); |
||||||
|
}); |
||||||
|
}; |
@ -1,6 +1,6 @@ |
|||||||
var sanitizeAll = require('../sanitiser/sanitizeAll'), |
var sanitizeAll = require('../sanitizer/sanitizeAll'), |
||||||
sanitizers = { |
sanitizers = { |
||||||
text: require('../sanitiser/_text_addressit') |
text: require('../sanitizer/_text_addressit') |
||||||
}; |
}; |
||||||
|
|
||||||
var sanitize = function(req, cb) { sanitizeAll(req, sanitizers, cb); }; |
var sanitize = function(req, cb) { sanitizeAll(req, sanitizers, cb); }; |
@ -1,4 +1,4 @@ |
|||||||
var sanitize = require('../../../sanitiser/_boundary_country'); |
var sanitize = require('../../../sanitizer/_boundary_country'); |
||||||
|
|
||||||
module.exports.tests = {}; |
module.exports.tests = {}; |
||||||
|
|
@ -1,4 +1,4 @@ |
|||||||
var sanitize = require( '../../../sanitiser/_categories'); |
var sanitize = require( '../../../sanitizer/_categories'); |
||||||
|
|
||||||
module.exports.tests = {}; |
module.exports.tests = {}; |
||||||
|
|
@ -1,4 +1,4 @@ |
|||||||
var sanitize = require('../../../sanitiser/_deprecate_quattroshapes'); |
var sanitize = require('../../../sanitizer/_deprecate_quattroshapes'); |
||||||
|
|
||||||
module.exports.tests = {}; |
module.exports.tests = {}; |
||||||
|
|
@ -1,4 +1,4 @@ |
|||||||
var sanitizer = require('../../../sanitiser/_flag_bool'); |
var sanitizer = require('../../../sanitizer/_flag_bool'); |
||||||
var sanitize = sanitizer('dirty_param', true); |
var sanitize = sanitizer('dirty_param', true); |
||||||
|
|
||||||
module.exports.tests = {}; |
module.exports.tests = {}; |
@ -1,4 +1,4 @@ |
|||||||
var sanitize = require('../../../sanitiser/_geo_common'); |
var sanitize = require('../../../sanitizer/_geo_common'); |
||||||
|
|
||||||
module.exports.tests = {}; |
module.exports.tests = {}; |
||||||
|
|
@ -1,4 +1,4 @@ |
|||||||
var sanitize = require('../../../sanitiser/_geo_reverse'); |
var sanitize = require('../../../sanitizer/_geo_reverse'); |
||||||
var defaults = require('../../../query/reverse_defaults'); |
var defaults = require('../../../query/reverse_defaults'); |
||||||
|
|
||||||
module.exports.tests = {}; |
module.exports.tests = {}; |
@ -1,4 +1,4 @@ |
|||||||
var groups = require('../../../sanitiser/_groups'); |
var groups = require('../../../sanitizer/_groups'); |
||||||
|
|
||||||
module.exports.tests = {}; |
module.exports.tests = {}; |
||||||
|
|
@ -1,4 +1,4 @@ |
|||||||
var sanitize = require('../../../sanitiser/_ids'); |
var sanitize = require('../../../sanitizer/_ids'); |
||||||
|
|
||||||
var delimiter = ':'; |
var delimiter = ':'; |
||||||
var type_mapping = require('../../../helper/type_mapping'); |
var type_mapping = require('../../../helper/type_mapping'); |
@ -1,6 +1,6 @@ |
|||||||
var type_mapping = require('../../../helper/type_mapping'); |
var type_mapping = require('../../../helper/type_mapping'); |
||||||
|
|
||||||
var sanitize = require('../../../sanitiser/_targets')('layers', type_mapping.layer_mapping); |
var sanitize = require('../../../sanitizer/_targets')('layers', type_mapping.layer_mapping); |
||||||
|
|
||||||
module.exports.tests = {}; |
module.exports.tests = {}; |
||||||
|
|
@ -1,4 +1,4 @@ |
|||||||
var sanitize = require('../../../sanitiser/_single_scalar_parameters'); |
var sanitize = require('../../../sanitizer/_single_scalar_parameters'); |
||||||
|
|
||||||
module.exports.tests = {}; |
module.exports.tests = {}; |
||||||
|
|
@ -1,4 +1,4 @@ |
|||||||
var sanitize = require('../../../sanitiser/_size'); |
var sanitize = require('../../../sanitizer/_size'); |
||||||
|
|
||||||
module.exports.tests = {}; |
module.exports.tests = {}; |
||||||
|
|
@ -1,5 +1,5 @@ |
|||||||
var type_mapping = require('../../../helper/type_mapping'); |
var type_mapping = require('../../../helper/type_mapping'); |
||||||
var sanitize = require( '../../../sanitiser/_targets' )('sources', type_mapping.source_mapping); |
var sanitize = require( '../../../sanitizer/_targets' )('sources', type_mapping.source_mapping); |
||||||
|
|
||||||
var success_messages = { error: false }; |
var success_messages = { error: false }; |
||||||
|
|
@ -1,4 +1,4 @@ |
|||||||
var sanitize = require('../../../sanitiser/_sources_and_layers'); |
var sanitize = require('../../../sanitizer/_sources_and_layers'); |
||||||
|
|
||||||
var type_mapping = require('../../../helper/type_mapping'); |
var type_mapping = require('../../../helper/type_mapping'); |
||||||
|
|
@ -1,4 +1,4 @@ |
|||||||
var sanitiser = require('../../../sanitiser/_text_addressit'); |
var sanitiser = require('../../../sanitizer/_text_addressit'); |
||||||
var type_mapping = require('../../../helper/type_mapping'); |
var type_mapping = require('../../../helper/type_mapping'); |
||||||
|
|
||||||
module.exports.tests = {}; |
module.exports.tests = {}; |
@ -1,4 +1,4 @@ |
|||||||
var isTruthy = require('../../../sanitiser/_truthy'); |
var isTruthy = require('../../../sanitizer/_truthy'); |
||||||
|
|
||||||
module.exports.tests = {}; |
module.exports.tests = {}; |
||||||
|
|
@ -1,14 +1,14 @@ |
|||||||
var autocomplete = require('../../../sanitiser/autocomplete'); |
var autocomplete = require('../../../sanitizer/autocomplete'); |
||||||
|
|
||||||
module.exports.tests = {}; |
module.exports.tests = {}; |
||||||
|
|
||||||
module.exports.tests.sanitisers = function(test, common) { |
module.exports.tests.sanitizers = function(test, common) { |
||||||
test('check sanitiser list', function (t) { |
test('check sanitizer list', function (t) { |
||||||
var expected = [ |
var expected = [ |
||||||
'singleScalarParameters', 'text', 'tokenizer', 'size', 'layers', 'sources', |
'singleScalarParameters', 'text', 'tokenizer', 'size', 'layers', 'sources', |
||||||
'sources_and_layers', 'private', 'geo_autocomplete', 'boundary_country', 'categories' |
'sources_and_layers', 'private', 'geo_autocomplete', 'boundary_country', 'categories' |
||||||
]; |
]; |
||||||
t.deepEqual(Object.keys(autocomplete.sanitiser_list), expected); |
t.deepEqual(Object.keys(autocomplete.sanitizer_list), expected); |
||||||
t.end(); |
t.end(); |
||||||
}); |
}); |
||||||
}; |
}; |
@ -1,4 +1,4 @@ |
|||||||
var sanitizeAll = require('../../../sanitiser/sanitizeAll'); |
var sanitizeAll = require('../../../sanitizer/sanitizeAll'); |
||||||
|
|
||||||
module.exports.tests = {}; |
module.exports.tests = {}; |
||||||
|
|
Loading…
Reference in new issue