for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace SimpleSAML\XML\Type;
use SimpleSAML\Assert\Assert;
use SimpleSAML\XML\Exception\SchemaViolationException;
/**
* @package simplesaml/xml-common
*/
class HexBinaryValue extends StringValue
{
* Sanitize the content.
*
* Note: There are no processing rules for xs:hexBinary regarding whitespace. General consensus is to strip them
* @param string $content The unsanitized content
* @throws \Exception on failure
* @return string
protected function sanitizeContent(string $content): string
return str_replace(["\f", "\r", "\n", "\t", "\v", ' '], '', $content);
}
* Validate the content of the element.
* @param string $content
* @throws \SimpleSAML\XML\Exception\SchemaViolationException on failure
* @return void
protected function validateContent(string $content): void
// Note: content must already be sanitized before validating
Assert::regex(
$this->sanitizeContent($content),
'/([0-9A-F]{2})*/i',
SchemaViolationException::class,
);