MCPcopy Create free account
hub / github.com/imgproxy/imgproxy / replaceEntities

Method replaceEntities

xmlparser/node.go:178–198  ·  view source on GitHub ↗

replaceEntities replaces XML entities in the node according to the provided entity map.

(em map[string][]byte)

Source from the content-addressed store, hash-verified

176// replaceEntities replaces XML entities in the node
177// according to the provided entity map.
178func (n *Node) replaceEntities(em map[string][]byte) {
179 // Replace in attributes
180 for attr := range n.Attrs.Iter() {
181 attr.Value = ReplaceEntitiesString(attr.Value, em)
182 }
183
184 // Replace in children.
185 // Only Text nodes are processed, other Node children
186 // are processed recursively.
187 for _, child := range n.Children {
188 switch c := child.(type) {
189 case *Node:
190 c.replaceEntities(em)
191
192 case *Text:
193 if !c.CData {
194 c.Data = ReplaceEntitiesBytes(c.Data, em)
195 }
196 }
197 }
198}

Callers 1

ReplaceEntitiesMethod · 0.80

Calls 3

ReplaceEntitiesStringFunction · 0.85
ReplaceEntitiesBytesFunction · 0.85
IterMethod · 0.80

Tested by

no test coverage detected