Remove unnecessary escape usage

This commit is contained in:
Daniel García Aubert 2019-10-24 19:18:47 +02:00
parent d5218a86f6
commit 575fe8e350
11 changed files with 17 additions and 18 deletions

View File

@ -45,7 +45,7 @@ module.exports = class TileLayergroupController {
route (mapRouter) {
// REGEXP: doesn't match with `val`
const not = (val) => `(?!${val})([^\/]+?)`;
const not = (val) => `(?!${val})([^\/]+?)`; // eslint-disable-line no-useless-escape
// Sadly the path that matches 1 also matches with 2 so we need to tell to express
// that performs only the middlewares of the first path that matches

View File

@ -81,7 +81,7 @@ TemplateMaps.prototype._redisCmd = function (redisFunc, redisArgs, callback) {
});
};
var _reValidNameIdentifier = /^[a-z0-9][0-9a-z_\-]*$/i;
var _reValidNameIdentifier = /^[a-z0-9][0-9a-z_-]*$/i;
var _reValidPlaceholderIdentifier = /^[a-z][0-9a-z_]*$/i;
// jshint maxcomplexity:15
TemplateMaps.prototype._checkInvalidTemplate = function (template) {
@ -429,7 +429,7 @@ TemplateMaps.prototype.isAuthorized = function (template, authTokens) {
//
// @throws Error on malformed template or parameter
//
var _reNumber = /^([-+]?[\d\.]?\d+([eE][+-]?\d+)?)$/;
var _reNumber = /^([-+]?[\d\.]?\d+([eE][+-]?\d+)?)$/; // eslint-disable-line no-useless-escape
var _reCSSColorName = /^[a-zA-Z]+$/;
var _reCSSColorVal = /^#[0-9a-fA-F]{3,6}$/;

View File

@ -28,7 +28,7 @@ function timeExpression (t, tz) {
function epochWithDefaults (epoch) {
/* jshint maxcomplexity:9 */ // goddammit linter, I like this as is!!
const format = /^(\d\d\d\d)(?:\-?(\d\d)(?:\-?(\d\d)(?:[T\s]?(\d\d)(?:(\d\d)(?:\:(\d\d))?)?)?)?)?$/;
const format = /^(\d\d\d\d)(?:\-?(\d\d)(?:\-?(\d\d)(?:[T\s]?(\d\d)(?:(\d\d)(?:\:(\d\d))?)?)?)?)?$/; // eslint-disable-line no-useless-escape
const match = (epoch || '').match(format) || [];
const year = match[1] || '0001';
const month = match[2] || '01';

View File

@ -118,7 +118,7 @@ function replace_table_in_query (sql, old_table_name, replacement) {
// since the pattern matches the first character of the table
// it must be put back in the replacement text
replacement = '$01' + replacement;
return '([^\.a-z0-9_]|^)';
return '([^\.a-z0-9_]|^)'; // eslint-disable-line no-useless-escape
}
}
@ -299,8 +299,7 @@ function should_use_overviews (query, data) {
}
function is_supported_query (sql) {
var basic_query =
/\s*SELECT\s+[\*a-z0-9_,\s]+?\s+FROM\s+((\"[^"]+\"|[a-z0-9_]+)\.)?(\"[^"]+\"|[a-z0-9_]+)\s*;?\s*/i;
var basic_query = /\s*SELECT\s+[\*a-z0-9_,\s]+?\s+FROM\s+((\"[^"]+\"|[a-z0-9_]+)\.)?(\"[^"]+\"|[a-z0-9_]+)\s*;?\s*/i; // eslint-disable-line no-useless-escape
var unwrapped_query = new RegExp('^' + basic_query.source + '$', 'i');
// queries for named maps are wrapped like this:
var wrapped_query = new RegExp(

View File

@ -3,7 +3,7 @@
// Quote an PostgreSQL identifier if ncecessary
function quote_identifier_if_needed (txt) {
if (txt && !txt.match(/^[a-z_][a-z_0-9]*$/)) {
return '"' + txt.replace(/\"/g, '""') + '"';
return '"' + txt.replace(/"/g, '""') + '"';
} else {
return txt;
}
@ -16,7 +16,7 @@ function parse_table_name (table) {
// parse table into 'parts' that may be quoted, each part
// in the parts array being an object { part: 'text', quoted: false/true }
var parts = [];
var splitted = table_name.split(/\"/);
var splitted = table_name.split(/"/);
for (var i = 0; i < splitted.length; i++) {
if (splitted[i] === '') {
if (parts.length > 0 && i < splitted.length - 1) {

View File

@ -302,10 +302,10 @@ describe('named-maps analysis', function () {
assert.deepStrictEqual(
JSON.parse(res.body),
{
errors: ['Unsupported image format \"gif\"'],
errors: ['Unsupported image format "gif"'],
errors_with_context: [{
type: 'unknown',
message: 'Unsupported image format \"gif\"'
message: 'Unsupported image format "gif"'
}]
}
);

View File

@ -612,10 +612,10 @@ describe('cluster', function () {
};
const invalidColumnExpressionsError = {
errors: ['column \"wadus\" does not exist'],
errors: ['column "wadus" does not exist'],
errors_with_context: [
{
message: 'column \"wadus\" does not exist',
message: 'column "wadus" does not exist',
type: 'unknown'
}
]

View File

@ -330,10 +330,10 @@ describe('named maps static view', function () {
assert.deepStrictEqual(
JSON.parse(res.body),
{
errors: ['Unsupported image format \"gif\"'],
errors: ['Unsupported image format "gif"'],
errors_with_context: [{
type: 'unknown',
message: 'Unsupported image format \"gif\"'
message: 'Unsupported image format "gif"'
}]
}
);

View File

@ -141,7 +141,7 @@ describe('static_maps', function () {
var parsedBody = JSON.parse(res.body);
assert.ok(parsedBody.errors);
assert.ok(parsedBody.errors.length);
assert.ok(parsedBody.errors[0].match(/column \"wadus\" does not exist/));
assert.ok(parsedBody.errors[0].match(/column "wadus" does not exist/));
done();
});
});

View File

@ -89,7 +89,7 @@ describe('turbo-carto error cases', function () {
assert.strictEqual(layergroup.errors.length, 1);
assert.ok(layergroup.errors[0].match(/^Failed\sto\sprocess/));
assert.ok(layergroup.errors[0].match(/unable\sto\scompute\sramp/i));
assert.ok(layergroup.errors[0].match(/invalid\smethod\s\"wadusmethod\"/i));
assert.ok(layergroup.errors[0].match(/invalid\smethod\s"wadusmethod"/i));
done();
});

View File

@ -124,7 +124,7 @@ describe('error-middleware', function () {
});
it('should escape chars that broke logs regex', function (done) {
const badString = 'error: ( ) = " \" \' * $ & |';
const badString = 'error: ( ) = " \" \' * $ & |'; // eslint-disable-line no-useless-escape
const escapedString = 'error ';
const error = new Error(badString);