MCPcopy Index your code
hub / github.com/XmirrorSecurity/OpenSCA-cli / popElement

Method popElement

opensca/sca/java/xml/xml.go:475–511  ·  view source on GitHub ↗

Record that we are ending an element with the given name. The name must match the record at the top of the stack, which must be a pushElement record. After popping the element, apply any undo records from the stack to restore the name translations that existed before we saw this element.

(t *EndElement)

Source from the content-addressed store, hash-verified

473// the stack to restore the name translations that existed
474// before we saw this element.
475func (d *Decoder) popElement(t *EndElement) bool {
476 s := d.pop()
477 name := t.Name
478 switch {
479 case s == nil || s.kind != stkStart:
480 d.err = d.syntaxError("unexpected end element </" + name.Local + ">")
481 return false
482 case s.name.Local != name.Local:
483 if !d.Strict {
484 d.needClose = true
485 d.toClose = t.Name
486 t.Name = s.name
487 return true
488 }
489 d.err = d.syntaxError("element <" + s.name.Local + "> closed by </" + name.Local + ">")
490 return false
491 case s.name.Space != name.Space:
492 d.err = d.syntaxError("element <" + s.name.Local + "> in space " + s.name.Space +
493 " closed by </" + name.Local + "> in space " + name.Space)
494 return false
495 }
496
497 d.translate(&t.Name, true)
498
499 // Pop stack until a Start or EOF is on the top, undoing the
500 // translations that were associated with the element we just closed.
501 for d.stk != nil && d.stk.kind != stkStart && d.stk.kind != stkEOF {
502 s := d.pop()
503 if s.ok {
504 d.ns[s.name.Local] = s.name.Space
505 } else {
506 delete(d.ns, s.name.Local)
507 }
508 }
509
510 return true
511}
512
513// If the top element on the stack is autoclosing and
514// t is not the end tag, invent the end tag.

Callers 1

TokenMethod · 0.95

Calls 3

popMethod · 0.95
syntaxErrorMethod · 0.95
translateMethod · 0.95

Tested by

no test coverage detected