فهرست منبع

HPCC-9177 Configmgr - Allow eclccserver option to contain dashes

Signed-off-by: Gleb Aronsky <gleb.aronsky@lexisnexis.com>
Gleb Aronsky 12 سال پیش
والد
کامیت
db87032070

+ 8 - 2
esp/files/scripts/configmgr/configmgr.js

@@ -952,10 +952,16 @@ function handleConfigCellClickEvent(oArgs, caller, isComplex) {
     }
 
     var regEx = new RegExp("^[a-zA-Z0-9_]+$");
+    var regEx2 = new RegExp("^[a-zA-Z0-9_-]+$");
 
-    if (attrName == 'name' && regEx.test(newValue) == false)
+    if (attrName == 'name' && record.getData('compType') == 'EclCCServerProcess' && !regEx2.test(newValue))
     {
-      alert("Invalid character in component name. Only alpha-numerics and underscores '_' are allowed.");
+      alert("Invalid character in component name. Only alpha-numerics, underscores, and dashes are allowed.");
+      return false;
+    }
+    else if (attrName == 'name' && !(record.getData('compType') == 'EclCCServerProcess') && !regEx.test(newValue))
+    {
+      alert("Invalid character in component name. Only alpha-numerics and underscores are allowed.");
       return false;
     }
     var xmlArgs = argsToXml(category, params, attrName, oldValue, newValue, recordIndex + 1, record.getData(column.key + '_onChange'));

+ 9 - 3
esp/services/WsDeploy/WsDeployService.cpp

@@ -980,9 +980,15 @@ bool CWsDeployFileInfo::navMenuEvent(IEspContext &context,
     return true;
 }//onNavMenuEvent
 
-bool CWsDeployFileInfo::isAlphaNumeric(const char *pstr) const
+bool CWsDeployFileInfo::isAlphaNumeric(const char *pstr, const char *pExprOverride) const
 {
-  RegExpr expr("[A-Za-z0-9-_]+");
+  StringBuffer regExpStr;
+
+  if (pExprOverride == NULL)
+      regExpStr.append("[A-Za-z0-9_]+");
+  else
+      regExpStr.append(pExprOverride);
+  RegExpr expr(regExpStr.str());
 
   return (expr.find(pstr) && expr.findlen(0) == strlen(pstr));
 }
@@ -1346,7 +1352,7 @@ bool CWsDeployFileInfo::saveSetting(IEspContext &context, IEspSaveSettingRequest
         {
           ensureUniqueName(pEnvRoot, pComp, pszNewValue);
 
-          if (isAlphaNumeric(pszNewValue) == false)
+          if (strcmp(pszCompType, "EclCCServerProcess") ? isAlphaNumeric(pszNewValue) == false : isAlphaNumeric(pszNewValue, "[-A-Za-z0-9_]+") == false)
           {
             throw MakeStringException(-1, "Invalid Character in name '%s'.", pszNewValue);
           }

+ 1 - 1
esp/services/WsDeploy/WsDeployService.hpp

@@ -462,7 +462,7 @@ public:
     virtual bool navMenuEvent(IEspContext &context, IEspNavMenuEventRequest &req, 
                                             IEspNavMenuEventResponse &resp);
     virtual bool displaySettings(IEspContext &context, IEspDisplaySettingsRequest &req, IEspDisplaySettingsResponse &resp);
-    virtual bool isAlphaNumeric(const char *pstr) const;
+    virtual bool isAlphaNumeric(const char *pstr, const char *pExprOverride = NULL) const;
     virtual bool saveSetting(IEspContext &context, IEspSaveSettingRequest &req, IEspSaveSettingResponse &resp);
     virtual bool getBuildSetInfo(IEspContext &context, IEspGetBuildSetInfoRequest &req, IEspGetBuildSetInfoResponse &resp);
     virtual bool getDeployableComps(IEspContext &context, IEspGetDeployableCompsRequest &req, IEspGetDeployableCompsResponse &resp);