Skip to content

Commit 6aeebff

Browse files
committed
Properly deal with QName in textContent
1 parent f9a52ce commit 6aeebff

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/TypedTextContentTrait.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use DOMElement;
88
use SimpleSAML\XML\Assert\Assert;
99
use SimpleSAML\XML\Exception\{InvalidDOMElementException, InvalidValueTypeException};
10-
use SimpleSAML\XML\Type\{ValueTypeInterface, StringValue};
10+
use SimpleSAML\XML\Type\{QNameValue, StringValue, ValueTypeInterface};
1111

1212
use function defined;
1313
use function strval;
@@ -40,9 +40,14 @@ public static function fromXML(DOMElement $xml): static
4040
Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class);
4141

4242
$type = self::getTextContentType();
43-
$text = $type::fromString($xml->textContent);
43+
if ($type === QNameValue::class) {
44+
$qName = QNameValue::fromDocument($xml->textContent, $xml);
45+
$text = $qName->getRawValue();
46+
} else {
47+
$text = $xml->textContent;
48+
}
4449

45-
return new static($text);
50+
return new static($type::fromString($text));
4651
}
4752

4853

0 commit comments

Comments
 (0)