File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed
Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -31,7 +31,21 @@ public function __construct(
3131 ) {
3232 }
3333
34+ /**
35+ * Validate that a string does not contain control characters.
36+ * Control characters (0x00-0x1F and 0x7F) can cause issues with URL routing and display.
37+ */
38+ public function containsControlCharacters (string $ value ): bool {
39+ return preg_match ('/[\x00-\x1F\x7F]/ ' , $ value ) === 1 ;
40+ }
41+
3442 public function registerDaemonConfig (array $ params ): ?DaemonConfig {
43+ $ name = $ params ['name ' ] ?? '' ;
44+ if ($ name === '' || $ this ->containsControlCharacters ($ name )) {
45+ $ this ->logger ->error ('Failed to register daemon configuration: `name` contains invalid characters or is empty. ' );
46+ return null ;
47+ }
48+
3549 if (!isset ($ params ['deploy_config ' ]['net ' ])) {
3650 $ this ->logger ->error ('Failed to register daemon configuration: `net` key should be present in the deploy config. ' );
3751 return null ;
@@ -133,6 +147,12 @@ public function getDaemonConfigByName(string $name): ?DaemonConfig {
133147 }
134148
135149 public function updateDaemonConfig (DaemonConfig $ daemonConfig ): ?DaemonConfig {
150+ $ name = $ daemonConfig ->getName () ?? '' ;
151+ if ($ name === '' || $ this ->containsControlCharacters ($ name )) {
152+ $ this ->logger ->error ('Failed to update daemon configuration: `name` contains invalid characters or is empty. ' );
153+ return null ;
154+ }
155+
136156 try {
137157 return $ this ->mapper ->update ($ daemonConfig );
138158 } catch (Exception $ e ) {
You can’t perform that action at this time.
0 commit comments