Keep placeholder key validation independent from name validation
This commit is contained in:
parent
3f0d344313
commit
9613f76ef5
@ -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
|
// jshint maxcomplexity:15
|
||||||
o._checkInvalidTemplate = function(template) {
|
o._checkInvalidTemplate = function(template) {
|
||||||
if ( template.version != '0.0.1' ) {
|
if ( template.version != '0.0.1' ) {
|
||||||
@ -98,7 +99,7 @@ o._checkInvalidTemplate = function(template) {
|
|||||||
if ( ! tplname ) {
|
if ( ! tplname ) {
|
||||||
return new Error("Missing template name");
|
return new Error("Missing template name");
|
||||||
}
|
}
|
||||||
if ( ! tplname.match(_reValidIdentifier) ) {
|
if ( ! tplname.match(_reValidNameIdentifier) ) {
|
||||||
return new Error("Invalid characters in template name '" + tplname + "'");
|
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++) {
|
for (var i = 0, len = placeholderKeys.length; i < len; i++) {
|
||||||
var placeholderKey = placeholderKeys[i];
|
var placeholderKey = placeholderKeys[i];
|
||||||
|
|
||||||
if (!placeholderKey.match(_reValidIdentifier)) {
|
if (!placeholderKey.match(_reValidPlaceholderIdentifier)) {
|
||||||
return new Error("Invalid characters in placeholder name '" + placeholderKey + "'");
|
return new Error("Invalid characters in placeholder name '" + placeholderKey + "'");
|
||||||
}
|
}
|
||||||
if ( ! placeholders[placeholderKey].hasOwnProperty('default') ) {
|
if ( ! placeholders[placeholderKey].hasOwnProperty('default') ) {
|
||||||
|
Loading…
Reference in New Issue
Block a user