admin: Preserve "@id" fields through partial changes (fixes #2902)

This commit is contained in:
Matthew Holt 2019-11-27 11:49:49 -07:00
parent 8de1a76227
commit 6e10586303
No known key found for this signature in database
GPG key ID: 2A349DD577D586A5
2 changed files with 33 additions and 11 deletions

View file

@ -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"