[php-src] Issue #12353: Valid XSD pattern throwing exception

From: Date: Tue, 03 Oct 2023 11:35:40 +0000
Subject: [php-src] Issue #12353: Valid XSD pattern throwing exception
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-245487@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/12353 Author: sdespont ### Description The following code: Where the XSD from [SIX ISO 2022 web site](https://www.six-group.com/dam/download/banking-services/standardization/sps/ig-credit-transfer-xml-schema-examples-sps2022-en.zip) is containing pattern : <xs:pattern value="[\p{IsBasicLatin}\p{IsLatin-1Supplement}\p{IsLatinExtended-A}€ȘșȚț-[\p{C}]]+"/> ```php <?php $xml = '<?xml version="1.0" encoding="UTF-8"?> <Document xmlns="urn:iso:std:iso:20022:tech:xsd:pain.001.001.09" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:iso:std:iso:20022:tech:xsd:pain.001.001.09 pain.001.001.09.ch.03.xsd"></Document>'; $schemaPath = __DIR__.'/pain.001.001.09.ch.03.xsd'; $doc = new DOMDocument(); $doc->loadXML($xml); libxml_use_internal_errors(true); try { $valid = $doc->schemaValidate($schemaPath); } catch (Exception $e) { $valid = false; } if ($valid === false) { var_dump(libxml_get_errors()); foreach (libxml_get_errors() as $error) { $this->fail($error->message); } } self::assertTrue($valid); libxml_clear_errors(); libxml_use_internal_errors(false); ``` Throw the following error : ``` array(4) { [0]=> object(LibXMLError)#594 (6) { ["level"]=> int(3) ["code"]=> int(1450) ["column"]=> int(0) ["message"]=> string(53) "failed to compile: Expecting the end of a char range " ["file"]=> string(0) "" ["line"]=> int(0) } [1]=> object(LibXMLError)#588 (6) { ["level"]=> int(3) ["code"]=> int(1450) ["column"]=> int(0) ["message"]=> string(53) "failed to compile: xmlFAParseCharClass: ']' expected " ["file"]=> string(0) "" ["line"]=> int(0) } [2]=> object(LibXMLError)#593 (6) { ["level"]=> int(3) ["code"]=> int(1450) ["column"]=> int(0) ["message"]=> string(54) "failed to compile: xmlFAParseRegExp: extra characters " ["file"]=> string(0) "" ["line"]=> int(0) } [3]=> object(LibXMLError)#596 (6) { ["level"]=> int(2) ["code"]=> int([17](https://github.com/sdespont/swiss-payment/actions/runs/6384316587/job/17326739456#step:7:18)56) ["column"]=> int(0) ["message"]=> string([20](https://github.com/sdespont/swiss-payment/actions/runs/6384316587/job/17326739456#step:7:21)6) "Element '{http://www.w3.org/2001/XMLSchema}pattern': The value '[\p{IsBasicLatin}\p{IsLatin-1Supplement}\p{IsLatinExtended-A}€ȘșȚț-[\p{C}]]+' of the facet 'pattern' is not a valid regular expression. " ["file"]=> string(77) "/home/runner/work/swiss-payment/swiss-payment/tests/pain.001.001.09.ch.03.xsd" ["line"]=> int(1[55](https://github.com/sdespont/swiss-payment/actions/runs/6384316587/job/17326739456#step:7:56)6) } } ``` But I expected this output instead: Should works because the regex pattern is valid. Tested with PHP 7.2, 7.3, 7.4, 8.0, 8.1 and 8.2 ### PHP Version 8.1, 8.2 ### Operating System Ubuntu 20.04

« previous php.bugs (#245487) next »