From 9613f76ef5a3615be9b3433bf50c4b8095f47516 Mon Sep 17 00:00:00 2001 From: Raul Ochoa Date: Thu, 4 Jun 2015 11:58:24 -0400 Subject: [PATCH] Keep placeholder key validation independent from name validation --- lib/cartodb/template_maps.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/cartodb/template_maps.js b/lib/cartodb/template_maps.js index c809b63f..d026fa7e 100644 --- a/lib/cartodb/template_maps.js +++ b/lib/cartodb/template_maps.js @@ -88,7 +88,8 @@ o._redisCmd = function(redisFunc, redisArgs, callback) { ); }; -var _reValidIdentifier = /^[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 o._checkInvalidTemplate = function(template) { if ( template.version != '0.0.1' ) { @@ -98,7 +99,7 @@ o._checkInvalidTemplate = function(template) { if ( ! tplname ) { return new Error("Missing template name"); } - if ( ! tplname.match(_reValidIdentifier) ) { + if ( ! tplname.match(_reValidNameIdentifier) ) { return new Error("Invalid characters in template name '" + tplname + "'"); } @@ -113,7 +114,7 @@ o._checkInvalidTemplate = function(template) { for (var i = 0, len = placeholderKeys.length; i < len; i++) { var placeholderKey = placeholderKeys[i]; - if (!placeholderKey.match(_reValidIdentifier)) { + if (!placeholderKey.match(_reValidPlaceholderIdentifier)) { return new Error("Invalid characters in placeholder name '" + placeholderKey + "'"); } if ( ! placeholders[placeholderKey].hasOwnProperty('default') ) {