Loosen restrictions on file names - allow underscores
authorColeman Watts <coleman@civicrm.org>
Wed, 8 Jan 2020 13:23:03 +0000 (08:23 -0500)
committerCiviCRM <info@civicrm.org>
Wed, 16 Sep 2020 02:13:21 +0000 (19:13 -0700)
ext/afform/core/Civi/Api4/Utils/AfformSaveTrait.php

index 837af3b5696bf11b4172c0194ac9bdfb3317a436..d35689ce8a4ab8d4ab11fe440bfcbfbf6aeb4264 100644 (file)
@@ -28,8 +28,8 @@ trait AfformSaveTrait {
       $item['name'] .= $suffix;
       $orig = NULL;
     }
-    elseif (!preg_match('/^[a-zA-Z][a-zA-Z0-9\-]*$/', $item['name'])) {
-      throw new \API_Exception("Afform.{$this->getActionName()}: name should use alphanumerics and dashes.");
+    elseif (!preg_match('/^[a-zA-Z][-_a-zA-Z0-9]*$/', $item['name'])) {
+      throw new \API_Exception("Afform.{$this->getActionName()}: name should begin with a letter and only contain alphanumerics underscores and dashes.");
     }
     else {
       // Fetch existing metadata