Bump reva deps (#8412)
* bump dependencies Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de> * bump reva and add config options Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de> --------- Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
This commit is contained in:
+1
@@ -10,3 +10,4 @@ Earncef Sequeira (earncef)
|
||||
Gabriel de Labachelerie (wuzuf)
|
||||
Martin Dosch (mdosch)
|
||||
Hugo Wetterberg (hugowetterberg)
|
||||
Tobias Theel (nerzal)
|
||||
|
||||
+1
@@ -1,4 +1,5 @@
|
||||
[](https://godoc.org/github.com/beevik/etree)
|
||||
[](https://github.com/beevik/etree/actions/workflows/go.yml)
|
||||
|
||||
etree
|
||||
=====
|
||||
|
||||
+9
@@ -1,3 +1,12 @@
|
||||
Release v1.3.0
|
||||
==============
|
||||
|
||||
**New Features**
|
||||
|
||||
* Add support for double-quotes in filter path queries.
|
||||
* Add `PreserveDuplicateAttrs` to `ReadSettings`.
|
||||
* Add `ReindexChildren` to `Element`.
|
||||
|
||||
Release v1.2.0
|
||||
==============
|
||||
|
||||
|
||||
+23
-7
@@ -46,6 +46,10 @@ type ReadSettings struct {
|
||||
// false.
|
||||
PreserveCData bool
|
||||
|
||||
// When an element has two or more attributes with the same name,
|
||||
// preserve them instead of keeping only one. Default: false.
|
||||
PreserveDuplicateAttrs bool
|
||||
|
||||
// Entity to be passed to standard xml.Decoder. Default: nil.
|
||||
Entity map[string]string
|
||||
}
|
||||
@@ -549,6 +553,15 @@ func (e *Element) name() string {
|
||||
return e.Tag
|
||||
}
|
||||
|
||||
// ReindexChildren recalculates the index values of the element's child
|
||||
// tokens. This is necessary only if you have manually manipulated the
|
||||
// element's `Child` array.
|
||||
func (e *Element) ReindexChildren() {
|
||||
for i := 0; i < len(e.Child); i++ {
|
||||
e.Child[i].setIndex(i)
|
||||
}
|
||||
}
|
||||
|
||||
// Text returns all character data immediately following the element's opening
|
||||
// tag.
|
||||
func (e *Element) Text() string {
|
||||
@@ -827,7 +840,7 @@ func (e *Element) readFrom(ri io.Reader, settings ReadSettings) (n int64, err er
|
||||
case xml.StartElement:
|
||||
e := newElement(t.Name.Space, t.Name.Local, top)
|
||||
for _, a := range t.Attr {
|
||||
e.createAttr(a.Name.Space, a.Name.Local, a.Value, e)
|
||||
e.createAttr(a.Name.Space, a.Name.Local, a.Value, e, settings.PreserveDuplicateAttrs)
|
||||
}
|
||||
stack.push(e)
|
||||
case xml.EndElement:
|
||||
@@ -1223,17 +1236,20 @@ func (e *Element) addChild(t Token) {
|
||||
// prefix followed by a colon.
|
||||
func (e *Element) CreateAttr(key, value string) *Attr {
|
||||
space, skey := spaceDecompose(key)
|
||||
return e.createAttr(space, skey, value, e)
|
||||
return e.createAttr(space, skey, value, e, false)
|
||||
}
|
||||
|
||||
// createAttr is a helper function that creates attributes.
|
||||
func (e *Element) createAttr(space, key, value string, parent *Element) *Attr {
|
||||
for i, a := range e.Attr {
|
||||
if space == a.Space && key == a.Key {
|
||||
e.Attr[i].Value = value
|
||||
return &e.Attr[i]
|
||||
func (e *Element) createAttr(space, key, value string, parent *Element, preserveDups bool) *Attr {
|
||||
if !preserveDups {
|
||||
for i, a := range e.Attr {
|
||||
if space == a.Space && key == a.Key {
|
||||
e.Attr[i].Value = value
|
||||
return &e.Attr[i]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
a := Attr{
|
||||
Space: space,
|
||||
Key: key,
|
||||
|
||||
+4
-4
@@ -299,10 +299,10 @@ func indentLF(n int, source string) string {
|
||||
}
|
||||
}
|
||||
|
||||
// nextIndex returns the index of the next occurrence of sep in s,
|
||||
// starting from offset. It returns -1 if the sep string is not found.
|
||||
func nextIndex(s, sep string, offset int) int {
|
||||
switch i := strings.Index(s[offset:], sep); i {
|
||||
// nextIndex returns the index of the next occurrence of byte ch in s,
|
||||
// starting from offset. It returns -1 if the byte is not found.
|
||||
func nextIndex(s string, ch byte, offset int) int {
|
||||
switch i := strings.IndexByte(s[offset:], ch); i {
|
||||
case -1:
|
||||
return -1
|
||||
default:
|
||||
|
||||
+35
-26
@@ -242,12 +242,17 @@ func splitPath(path string) []string {
|
||||
var pieces []string
|
||||
start := 0
|
||||
inquote := false
|
||||
var quote byte
|
||||
for i := 0; i+1 <= len(path); i++ {
|
||||
if path[i] == '\'' {
|
||||
inquote = !inquote
|
||||
} else if path[i] == '/' && !inquote {
|
||||
pieces = append(pieces, path[start:i])
|
||||
start = i + 1
|
||||
if !inquote {
|
||||
if path[i] == '\'' || path[i] == '"' {
|
||||
inquote, quote = true, path[i]
|
||||
} else if path[i] == '/' {
|
||||
pieces = append(pieces, path[start:i])
|
||||
start = i + 1
|
||||
}
|
||||
} else if path[i] == quote {
|
||||
inquote = false
|
||||
}
|
||||
}
|
||||
return append(pieces, path[start:])
|
||||
@@ -302,30 +307,34 @@ func (c *compiler) parseFilter(path string) filter {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Filter contains [@attr='val'], [fn()='val'], or [tag='val']?
|
||||
eqindex := strings.Index(path, "='")
|
||||
if eqindex >= 0 {
|
||||
rindex := nextIndex(path, "'", eqindex+2)
|
||||
if rindex != len(path)-1 {
|
||||
c.err = ErrPath("path has mismatched filter quotes.")
|
||||
return nil
|
||||
}
|
||||
// Filter contains [@attr='val'], [@attr="val"], [fn()='val'],
|
||||
// [fn()="val"], [tag='val'] or [tag="val"]?
|
||||
eqindex := strings.IndexByte(path, '=')
|
||||
if eqindex >= 0 && eqindex+1 < len(path) {
|
||||
quote := path[eqindex+1]
|
||||
if quote == '\'' || quote == '"' {
|
||||
rindex := nextIndex(path, quote, eqindex+2)
|
||||
if rindex != len(path)-1 {
|
||||
c.err = ErrPath("path has mismatched filter quotes.")
|
||||
return nil
|
||||
}
|
||||
|
||||
key := path[:eqindex]
|
||||
value := path[eqindex+2 : rindex]
|
||||
key := path[:eqindex]
|
||||
value := path[eqindex+2 : rindex]
|
||||
|
||||
switch {
|
||||
case key[0] == '@':
|
||||
return newFilterAttrVal(key[1:], value)
|
||||
case strings.HasSuffix(key, "()"):
|
||||
name := key[:len(key)-2]
|
||||
if fn, ok := fnTable[name]; ok {
|
||||
return newFilterFuncVal(fn, value)
|
||||
switch {
|
||||
case key[0] == '@':
|
||||
return newFilterAttrVal(key[1:], value)
|
||||
case strings.HasSuffix(key, "()"):
|
||||
name := key[:len(key)-2]
|
||||
if fn, ok := fnTable[name]; ok {
|
||||
return newFilterFuncVal(fn, value)
|
||||
}
|
||||
c.err = ErrPath("path has unknown function " + name)
|
||||
return nil
|
||||
default:
|
||||
return newFilterChildText(key, value)
|
||||
}
|
||||
c.err = ErrPath("path has unknown function " + name)
|
||||
return nil
|
||||
default:
|
||||
return newFilterChildText(key, value)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user