diff --git a/sanitiser/_details.js b/sanitiser/_details.js index 2b568dd9..6e51f829 100644 --- a/sanitiser/_details.js +++ b/sanitiser/_details.js @@ -19,12 +19,15 @@ function sanitize( req, default_value ){ if (params.details !== undefined) { var details = params.details; - + if (typeof params.details === 'string') { - details = params.details === 'true'; + details = params.details === 'true' || + params.details === '1' || + params.details === 'yes' || + params.details === 'y'; } - clean.details = details === true || details === 1; + clean.details = details === true || details === 1; } else { clean.details = default_value; } diff --git a/test/unit/sanitiser/reverse.js b/test/unit/sanitiser/reverse.js index 6dbcda3a..bb1a6a98 100644 --- a/test/unit/sanitiser/reverse.js +++ b/test/unit/sanitiser/reverse.js @@ -137,7 +137,7 @@ module.exports.tests.sanitize_details = function(test, common) { }); }); - var valid_values = [true, 'true', 1]; + var valid_values = [true, 'true', 1, '1', 'yes', 'y']; valid_values.forEach(function(details) { test('valid details param ' + details, function(t) { sanitize({ input: 'test', lat: 0, lon: 0, details: details }, function( err, clean ){ @@ -154,7 +154,7 @@ module.exports.tests.sanitize_details = function(test, common) { }); }); - var valid_false_values = ['false', false, 0]; + var valid_false_values = ['false', false, 0, '0', 'no', 'n']; valid_false_values.forEach(function(details) { test('test setting false explicitly ' + details, function(t) { sanitize({ input: 'test', lat: 0, lon: 0, details: details }, function( err, clean ){ diff --git a/test/unit/sanitiser/search.js b/test/unit/sanitiser/search.js index 37763165..77377c94 100644 --- a/test/unit/sanitiser/search.js +++ b/test/unit/sanitiser/search.js @@ -278,7 +278,7 @@ module.exports.tests.sanitize_details = function(test, common) { }); }); - var valid_values = ['true', true, 1]; + var valid_values = ['true', true, 1, '1', 'yes', 'y']; valid_values.forEach(function(details) { test('valid details param ' + details, function(t) { sanitize({ input: 'test', lat: 0, lon: 0, details: details }, function( err, clean ){ @@ -288,7 +288,7 @@ module.exports.tests.sanitize_details = function(test, common) { }); }); - var valid_false_values = ['false', false, 0]; + var valid_false_values = ['false', false, 0, '0', 'no', 'n']; valid_false_values.forEach(function(details) { test('test setting false explicitly ' + details, function(t) { sanitize({ input: 'test', lat: 0, lon: 0, details: details }, function( err, clean ){