Commit a655630
committed
fix(Xml): XmlReader::Create could not open a file under a non-ASCII path on Windows
Found by running CNA's content suite with TEMP pointed at a directory whose name
is not representable in the process code page: every XML source under it failed
with XML_ERROR_FILE_NOT_FOUND while the file was plainly there.
tinyxml2 opens with fopen/fopen_s (vendor/tinyxml2/tinyxml2.cpp:2316-2327),
which is the ANSI code page on Windows and has no wide branch. This is the same
shape as stb_image and cgltf, and it gets the same treatment: do not hand the
library a filename.
tinyxml2's FILE* overload of LoadFile takes the file already open, so the OPEN
happens through a wide path while every one of tinyxml2's own error codes and
its BOM and encoding handling stay exactly as they were. On a failure to widen
or open, it falls through to the original call so tinyxml2 still reports its own
XML_ERROR_FILE_NOT_FOUND rather than leaving a silently empty document.
The narrow std::string this API takes means UTF-8, as it does throughout.
Linux: 562/562 Xml tests pass. The added code is inside `#if defined(_WIN32)`.1 parent 491b937 commit a655630
1 file changed
Lines changed: 40 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
5 | 15 | | |
6 | 16 | | |
7 | 17 | | |
| |||
572 | 582 | | |
573 | 583 | | |
574 | 584 | | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
575 | 614 | | |
576 | 615 | | |
577 | 616 | | |
| |||
590 | 629 | | |
591 | 630 | | |
592 | 631 | | |
593 | | - | |
| 632 | + | |
594 | 633 | | |
595 | 634 | | |
596 | 635 | | |
| |||
0 commit comments