http://bugs.winehq.org/show_bug.cgi?id=29685
Bug #: 29685 Summary: Manifest generator (ecmangen) tool from Windows Platform SDK 7.1 crashes due to unhandled facet/regular expression in XML schema (escape sequence) Product: Wine Version: 1.3.37 Platform: x86 OS/Version: Linux Status: NEW Severity: normal Priority: P2 Component: msxml3 AssignedTo: wine-bugs@winehq.org ReportedBy: focht@gmx.net Classification: Unclassified
Hello,
the "ecmangen" tool (Manifest generator gui) crashes due to unhandled facet/regular expression in XML schema.
--- snip --- $ pwd /home/focht/.wine/drive_c/Program Files/Microsoft SDKs/Windows/v7.1/Bin ... $ wine ./ecmangen.exe --- snip ---
Trace log:
--- snip --- ... 0025:trace:msxml:domdoc_QueryInterface (0x1503c8)->({4f2f4ba2-b822-11df-8b8a-6850dfd72085} 0x32f71c) 0025:trace:msxml:node_query_interface (0x1503c8)->(IID_xmlnode 0x32f71c) ... 0025:trace:msxml:Schema_parse (0x7c96a400) regexp error : failed to compile: Wrong escape sequence, misuse of character '' regexp error : failed to compile: internal: no atom generated regexp error : failed to compile: genrate transition: atom == NULL regexp error : failed to compile: xmlFAParseAtom: expecting ')' regexp error : failed to compile: xmlFAParseRegExp: extra characters 0025:err:msxml:Schema_parse "Element '{http://www.w3.org/2001/XMLSchema%7Dpattern': The value '(\$\([Ss]tring\..*\))|(\$\([Mm][Cc]\..*\))' of the facet 'pattern' is not a valid regular expression.\n"failed to parse doc ... 0025:Call oleaut32.SysAllocString(0015034c L"Failed trying to add schema file to cache.") ret=0100adc3 ... 0025:Call msvcrt._CxxThrowException(0032f848,01041d10) ret=01039b9e ... 0025:Call KERNEL32.MultiByteToWideChar(00000000,00000000,6868ef1a "Runtime error!",0000000e,0032e7c8,00000400) ret=6866169a 0025:Ret KERNEL32.MultiByteToWideChar() retval=0000000e ret=6866169a 0025:Call KERNEL32.MultiByteToWideChar(00000000,00000000,6868ef43 "abnormal program termination",0000001c,0032dfc8,00000400) ret=6866169a --- snip ---
The relevant part of XML schema:
--- snip --- <xs:schema targetNamespace="http://schemas.microsoft.com/win/2004/08/events" elementFormDefault="qualified" xmlns:man="http://schemas.microsoft.com/win/2004/08/events" xmlns:xs="http://www.w3.org/2001/XMLSchema%22%3E ... <xs:simpleType name="strTableRef"> xs:annotation xs:documentation Value of this attribute should be of the form $(string.stringTableId), where stringTableId is the 'id' attribute of a <string> element defined in the <stringTable> section. Or it could be of the form $(mc.mcSymbolId), where mcSymbolId is the symbol of a message string defined in a .mc file. </xs:documentation> </xs:annotation> <xs:restriction base="xs:string"> <xs:pattern value="($([Ss]tring..*))|($([Mm][Cc]..*))"/> </xs:restriction> </xs:simpleType> --- snip ---
'winetricks -q msxml6' works around.
Regards
http://bugs.winehq.org/show_bug.cgi?id=29685
Anastasius Focht focht@gmx.net changed:
What |Removed |Added ---------------------------------------------------------------------------- Keywords| |download URL| |http://www.microsoft.com/do | |wnload/en/details.aspx?id=8 | |279
--- Comment #1 from Anastasius Focht focht@gmx.net 2012-01-22 14:47:43 CST --- Hello,
filling fields. SDK 7.1 installer needs .NET 4.0 Framework prerequisite installed
$ sha1sum winsdk_web.exe a8717ebb20a69c7efa85232bcb9899b8b07f98cf winsdk_web.exe
$ wine --version wine-1.3.37-254-g14b790a
Regards
http://bugs.winehq.org/show_bug.cgi?id=29685
--- Comment #2 from Anastasius Focht focht@gmx.net 2013-05-03 05:12:34 CDT --- Hello folks,
revisiting, still present.
$ wine --version wine-1.5.29-107-gb94cfaf
Regards
https://bugs.winehq.org/show_bug.cgi?id=29685
--- Comment #3 from Anastasius Focht focht@gmx.net --- Hello folks,
revisiting, still present.
$ wine --version wine-1.7.40-29-gc1c108f
Regards
https://bugs.winehq.org/show_bug.cgi?id=29685
--- Comment #4 from Anastasius Focht focht@gmx.net --- Hello folks,
revisiting, still present.
In Windows Platform SDK 7.1 web installer deselect everything except 'Windows native Code Development' -> 'Tools' to save download/install time.
$ sha1sum winsdk_web.exe a8717ebb20a69c7efa85232bcb9899b8b07f98cf winsdk_web.exe
$ du -sh winsdk_web.exe 500K winsdk_web.exe
$ wine --version wine-4.3-188-gab7756619c
Regards
https://bugs.winehq.org/show_bug.cgi?id=29685
Anastasius Focht focht@gmx.net changed:
What |Removed |Added ---------------------------------------------------------------------------- URL|http://www.microsoft.com/do |https://web.archive.org/web |wnload/en/details.aspx?id=8 |/20101226004523/http://down |279 |load.microsoft.com/download | |/A/6/A/A6AC035D-DA3F-4F0C-A | |DA4-37C8E5D34E3D/winsdk_web | |.exe
--- Comment #5 from Anastasius Focht focht@gmx.net --- Hello folks,
revisiting, still present.
Adding stable link via Internet Archive.
https://web.archive.org/web/20101226004523/http://download.microsoft.com/dow...
$ wine --version wine-5.9
Regards
https://bugs.winehq.org/show_bug.cgi?id=29685
Damjan Jovanovic damjan.jov@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |damjan.jov@gmail.com
--- Comment #6 from Damjan Jovanovic damjan.jov@gmail.com --- That xs:pattern snippet can be used to reproduce this bug with the command line "xmllint" tool. Here's a quickly cobbled together example.
x.xml:
---snip--- <?xml version="1.0"?> <note xmlns="https://www.w3schools.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="file:///tmp/x.xsd"> <strTableRef>$(string.a)</strTableRef> </note> ---snip---
/tmp/x.xsd: (uncommented line broken, commented line below it working)
---snip--- <?xml version="1.0"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="https://www.w3schools.com" xmlns="https://www.w3schools.com" elementFormDefault="qualified"> <xs:element name="note"> xs:complexType xs:sequence <xs:element name="strTableRef"> xs:simpleType <xs:restriction base="xs:string"> <xs:pattern value="($([Ss]tring..*))|($([Mm][Cc]..*))"/> <!-- <xs:pattern value="($\([Ss]tring\..*\))|($\([Mm][Cc]\..*\))"/> --> </xs:restriction> </xs:simpleType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:schema> ---snip---
And to test:
---snip--- $ xmllint --schema /tmp/x.xsd x.xml --noout regexp error : failed to compile: Wrong escape sequence, misuse of character '' regexp error : failed to compile: internal: no atom generated regexp error : failed to compile: generate transition: atom == NULL regexp error : failed to compile: xmlFAParseAtom: expecting ')' regexp error : failed to compile: xmlFAParseRegExp: extra characters x.xsd:13: element pattern: Schemas parser error : Element '{http://www.w3.org/2001/XMLSchema%7Dpattern': The value '($([Ss]tring..*))|($([Mm][Cc]..*))' of the facet 'pattern' is not a valid regular expression. WXS schema x.xsd failed to compile ---snip---
Swap the commented and uncommented lines in /tmp/x.xsd around, and:
---snip--- $ xmllint --schema /tmp/x.xsd x.xml --noout x.xml validates ---snip---
Note the problem: MSXML is apparently ok with "$" in the regex, but to libxml2 that's an error, it never allows "$" after a "".
As per Appendix F of https://www.w3.org/TR/2004/REC-xmlschema-2-20041028/datatypes.html#regexs it seems that "$" really shouldn't be allowed, but MSXML allows it anyway; ie. MSXML uses a non-conforming regex dialect where additional characters are allowed.
Bug #43581 has the same issue with various "\u####" regex sequences and could be considered a duplicate of this one.
While for this we could make a regex parser that rewrites MSXML's dialect into libxml2's, regex in XML sadly doesn't end at schema validation, eg. XSLT 2 uses it as well (https://www.xml.com/pub/a/2003/06/04/tr.html). If MSXSML uses the same regex dialect for other things, and we can't change that regex in transit between its origin and libxml2, then we may need to ship a private fork of libxml2 patched to use MSXML's dialect internally.
https://bugs.winehq.org/show_bug.cgi?id=29685
--- Comment #7 from Damjan Jovanovic damjan.jov@gmail.com --- The sad state of how different XML implementations handle "$" in the input string:
| Regex in XSD's xs:pattern Implementation | $ | $ -----------------+-------------------+----------------- libxml2 | Error | Validates Java | Validates | Validates .NET Core 3 | Validates | Error Mono | Validates | Error MSXML6 (Windows) | Validates | Validates
It's possible the developers of ecmangen were motivated to use "$" due to the fact it works on both .NET and MSXML.
https://bugs.winehq.org/show_bug.cgi?id=29685
--- Comment #8 from Damjan Jovanovic damjan.jov@gmail.com --- Patch to libxml2 that implements this and many other non-standard escape sequences used by MSXML: https://gitlab.gnome.org/GNOME/libxml2/-/merge_requests/116
https://bugs.winehq.org/show_bug.cgi?id=29685
Damjan Jovanovic damjan.jov@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Keywords| |source
--- Comment #9 from Damjan Jovanovic damjan.jov@gmail.com --- (In reply to Damjan Jovanovic from comment #8)
Patch to libxml2 that implements this and many other non-standard escape sequences used by MSXML: https://gitlab.gnome.org/GNOME/libxml2/-/merge_requests/116
Support for these non-standard XSD regex escape sequences was recently added to the upstream libxml2 master branch by these commits: ec8ff95ce3c92caaa23e70b5df80418d83abd83d b66c19612c16e1070d42ce13a444d806fd49755b 37ebf8a8b2789037792cfc0264b814d742cda2d9
It should be included in its next release. When we import the next libxml2 release, this bug will be fixed, and can then be closed.
https://bugs.winehq.org/show_bug.cgi?id=29685
--- Comment #10 from Damjan Jovanovic damjan.jov@gmail.com --- libxml2 2.10.0 has now been released and fixes this bug. Can we import it into our tree?
https://bugs.winehq.org/show_bug.cgi?id=29685
Damjan Jovanovic damjan.jov@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Fixed by SHA1| |015491ab32742ace5218d37b114 | |9c58803858214 Resolution|--- |FIXED
--- Comment #11 from Damjan Jovanovic damjan.jov@gmail.com --- In commit 015491ab32742ace5218d37b1149c58803858214 we start using libxml2 2.10.0. Thank you Alexandre. Resolving FIXED.
https://bugs.winehq.org/show_bug.cgi?id=29685
Alexandre Julliard julliard@winehq.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |CLOSED
--- Comment #12 from Alexandre Julliard julliard@winehq.org --- Closing bugs fixed in 7.16.