@@ -17,6 +17,7 @@ package haproxy
1717import (
1818 "context"
1919 "log/slog"
20+ "regexp"
2021
2122 "github.com/haproxytech/haproxy-unified-gateway/k8s/gate/haproxy/storage/maps"
2223 "github.com/haproxytech/haproxy-unified-gateway/k8s/gate/logging"
@@ -25,6 +26,8 @@ import (
2526 "github.com/haproxytech/haproxy-unified-gateway/k8s/gate/utils"
2627)
2728
29+ var re = regexp .MustCompile (`\\+` )
30+
2831// ErrMapRuntimeUpdate is an error type for runtime map update failures
2932type ErrMapRuntimeUpdate struct {
3033 Err error
@@ -194,8 +197,6 @@ func (b *RouteMgrImpl) writeMaps() error {
194197
195198// runtimeMapSync updates the runtime maps through runtime API
196199func (b * RouteMgrImpl ) runtimeMapSync () error {
197- b .topManager .logger .LogAttrs (context .Background (), slog .LevelInfo , "map [runtime] updates" )
198-
199200 mapsStorage := b .topManager .params .mapsStorageEx
200201 runtimeClient := b .topManager .haproxyClient .RuntimeClient ()
201202
@@ -218,7 +219,7 @@ func (b *RouteMgrImpl) runtimeMapSync() error {
218219 continue
219220 }
220221 for entryKey , entryValue := range mapData .Entries {
221- key := entryKey .Hostname
222+ key := escapeSlashForRuntime ( entryKey .Hostname )
222223 if entryKey .Path != "" {
223224 key += entryKey .Path
224225 }
@@ -287,3 +288,9 @@ func (b *RouteMgrImpl) getMapID(fullPath string) (string, error) {
287288 }
288289 return "" , nil
289290}
291+
292+ func escapeSlashForRuntime (key string ) string {
293+ return re .ReplaceAllStringFunc (key , func (s string ) string {
294+ return `\` + s
295+ })
296+ }
0 commit comments