1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-10-23 01:52:48 +03:00

Do normalize string-based datatype value in RelaxNG facet checking

Original patch is from Jan Pokorný <jpokorny redhat com>
https://mail.gnome.org/archives/xml/2013-November/msg00028.html

Improve it according to reviews and add test files.
This commit is contained in:
Audric Schiltknecht
2016-04-15 22:41:24 +08:00
committed by Daniel Veillard
parent 27aae65156
commit cad102b861
6 changed files with 68 additions and 47 deletions

View File

@@ -5315,7 +5315,15 @@ xmlSchemaValidateFacetInternal(xmlSchemaFacetPtr facet,
*/
if (value == NULL)
return(-1);
ret = xmlRegexpExec(facet->regexp, value);
/*
* If string-derived type, regexp must be tested on the value space of
* the datatype.
* See https://www.w3.org/TR/xmlschema-2/#rf-pattern
*/
const int stringType = val && ((val->type >= XML_SCHEMAS_STRING && val->type <= XML_SCHEMAS_NORMSTRING)
|| (val->type >= XML_SCHEMAS_TOKEN && val->type <= XML_SCHEMAS_NCNAME));
ret = xmlRegexpExec(facet->regexp,
(stringType && val->value.str) ? val->value.str : value);
if (ret == 1)
return(0);
if (ret == 0)