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

Method readAttrValue

xmlparser/decoder.go:333–360  ·  view source on GitHub ↗

readAttrValue reads an attribute value.

()

Source from the content-addressed store, hash-verified

331
332// readAttrValue reads an attribute value.
333func (d *Decoder) readAttrValue() ([]byte, bool) {
334 d.buf.Reset()
335
336 b, ok := d.mustReadByte()
337 if !ok {
338 return nil, false
339 }
340
341 if b == '"' || b == '\'' {
342 // Quoted attribute value
343 // We can just read until the closing quote.
344 if !d.mustReadUntil(b) {
345 return nil, false
346 }
347 // Remove the trailing quote from the buffer
348 d.buf.Remove(1)
349 } else {
350 // Unquoted attribute value.
351 // Unread the byte for further processing
352 d.unreadByte(b)
353 // Read until we meet a byte that is not valid in an unquoted attribute value.
354 if !d.mustReadWhileFn(isValueByte) {
355 return nil, false
356 }
357 }
358
359 return d.buf.Bytes(), true
360}
361
362// isValueByte checks if a byte is valid in an unquoted attribute value.
363// See: https://www.w3.org/TR/REC-html40/intro/sgmltut.html#h-3.2.2

Callers 1

readStartTagMethod · 0.95

Calls 7

mustReadByteMethod · 0.95
mustReadUntilMethod · 0.95
unreadByteMethod · 0.95
mustReadWhileFnMethod · 0.95
ResetMethod · 0.80
RemoveMethod · 0.80
BytesMethod · 0.80

Tested by

no test coverage detected