diff --git a/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Caches/PrivilegesCache.inc b/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Caches/PrivilegesCache.inc index fa196bf26..095278d6b 100644 --- a/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Caches/PrivilegesCache.inc +++ b/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Caches/PrivilegesCache.inc @@ -25,10 +25,10 @@ class PrivilegesCache extends Cache { $privs += $endpoint_object->generate_pfsense_privs(); } - # Obtain privileges for each Endpoint class - foreach (get_classes_from_namespace('\\RESTAPI\\Forms\\') as $endpoint_class) { - $endpoint_object = new $endpoint_class(); - $privs += $endpoint_object->generate_pfsense_privs(); + # Obtain privileges for each Form class + foreach (get_classes_from_namespace('\\RESTAPI\\Forms\\') as $form_class) { + $form_object = new $form_class(); + $privs += $form_object->generate_pfsense_privs(); } return $privs; diff --git a/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Core/Form.inc b/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Core/Form.inc index d90e39454..769d1d195 100644 --- a/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Core/Form.inc +++ b/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Core/Form.inc @@ -165,7 +165,17 @@ class Form { private function generate_verbose_name(): string { # Separate the class name's words with spaces, allow consecutive capital characters like 'DNS' $form_name = $this->get_class_shortname(); - return preg_replace('/(?<=[a-z])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])/', ': ', $form_name); + $verbose_name = preg_replace('/(?<=[a-z])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])/', ' ', $form_name); + + # Add a colon after the first word if the class name is more than one word + if (str_contains($verbose_name, ' ')) { + $verbose_name = explode(' ', $verbose_name); + $verbose_name[0] .= ': '; + $verbose_name = implode(' ', $verbose_name); + } + + # Return the verbose name with the 'Form' suffix removed + return str_replace(' Form', '', $verbose_name); } /** @@ -513,6 +523,7 @@ class Form { $this->get_priv_name() => [ 'name' => 'WebCfg - ' . $this->verbose_name, 'descr' => "Allow access to the $this->url page.", + 'match' => [substr($this->url, 1)], ], ]; }