diff options
author | Matthew Holt <[email protected]> | 2019-11-27 11:49:49 -0700 |
---|---|---|
committer | Matthew Holt <[email protected]> | 2019-11-27 11:49:49 -0700 |
commit | 6e10586303fd90f0298c8086e754b35dfc3f01ba (patch) | |
tree | 68dc2ba044debe5f4a75cebfc29d044a6064d1bd /admin.go | |
parent | 8de1a762273323608d9d9080c42057d1814070b6 (diff) | |
download | caddy-6e10586303fd90f0298c8086e754b35dfc3f01ba.tar.gz caddy-6e10586303fd90f0298c8086e754b35dfc3f01ba.zip |
admin: Preserve "@id" fields through partial changes (fixes #2902)
Diffstat (limited to 'admin.go')
-rw-r--r-- | admin.go | 7 |
1 files changed, 7 insertions, 0 deletions
@@ -27,6 +27,7 @@ import ( "net/url" "os" "path" + "regexp" "strconv" "strings" "sync" @@ -764,6 +765,12 @@ var ( } ) +// idRegexp is used to match ID fields and their associated values +// in the config. It also matches adjacent commas so that syntax +// can be preserved no matter where in the object the field appears. +// It supports string and most numeric values. +var idRegexp = regexp.MustCompile(`(?m),?\s*"` + idKey + `":\s?(-?[0-9]+(\.[0-9]+)?|(?U)".*")\s*,?`) + const ( rawConfigKey = "config" idKey = "@id" |