-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Xslt document function fails when path Contains Private Area Unicode Characters #59353
Comments
Tagging subscribers to this area: @buyaa-n, @krwq Issue DetailsDescriptionOriginal issue: dotnet/msbuild#6847 Initializing an XmlReader using The workaround is to call XmlReader.Create using a StreamReader. However, when MSBuild is calling its ConfigurationFull framework & net core 6.0.100-preview.7.21379.14 Regression?No Other informationSee original issue / MSBuild PR for in-depth notes.
|
@benvillalobos can you provide a minimal repro? Ideally something which creates a file on the fly and uses string path = @"Ⅻㄨㄩ 啊阿鼾齄丂丄狚狛狜狝﨨﨩ˊˋ˙–⿻〇㐀㐁䶴䶵.xml";
string content = @"<root></root>";
File.WriteAllText(path, content);
using XmlReader reader = XmlReader.Create(path); and getting no exception. What's the exception you're getting? |
You'll need to include |
@benvillalobos what is the exception you're seeing? |
from the e-mail conversation this might be blocking msbuild team so changing milestone |
OH, apologies. The title for this issue was incorrect. See this comment for details: dotnet/msbuild#6863 (comment) Exception gets thrown on this line https://github.com/dotnet/msbuild/blob/main/src/Tasks/XslTransformation.cs#L176 In summary, when transforming an xslt doc who's path contains the unicode mess ( |
Also this isn't a blocking issue. We worked around one aspect of the issue which was loading the xslt doc in the first place. But we also see the error when trying to load another document while transforming the first. |
@benvillalobos any chance you could create a project with a tiny repro? |
Steps to reproduce: Note: If you have the latest and greatest VS, it probably already has this change. So
You should get the error Open up MSBuild.Dev.slnf in VS. On same command line: Place a breakpoint in the line I mentioned the exception gets thrown (2 comments above) |
IMO this seems to be caused by unexpected behaviour in This test program tests the foreach (var name in new[] { "a", "\u00A1", "\u0800", "\U00010000", "\uE000" })
{
var filePath = $@"C:\Temp\{name}.txt";
var uri = new Uri(filePath);
Console.WriteLine("{0}\t{1}\t{2}\t{3}", uri.LocalPath == filePath, filePath, uri.AbsoluteUri, uri.LocalPath);
} The output shows that the file path does round-trip for everything except the PUA character, which is double-encoded in the URI.
I haven't consulted the URI RFC to determine whether this would be considered correct. You don't get the same failure to round-trip for If |
I wonder if runtime/src/libraries/System.Private.Uri/src/System/IriHelper.cs Lines 16 to 22 in c00b068
A fix would be to change this line of code as follows:
uri = new Uri(Path.GetFullPath(relativeUri!), new UriCreationOptions { DangerousDisablePathAndQueryCanonicalization = true }); However, I don't know the security implications of this, given the property name. |
I guess, since you can pass your own XmlResolver possibly you can just derive and apply workaround in the new type. We should still figure out if this is XML or Uri issue. The @karelz do we have any Uri experts who could help with the questions above? |
Description
Original issue: dotnet/msbuild#6847
MSBuild's PR: dotnet/msbuild#6863
Initializing an XmlReader usingXmlReader.Create(<path-to-file>)
where the path contains characters from the unicode private use area causes issues at file load. Part of the path that's the culprit:Ⅻㄨㄩ 啊阿鼾齄丂丄狚狛狜狝﨨﨩ˊˋ˙–⿻〇㐀㐁䶴䶵U1[]U2[]U3[]
The workaround is to call XmlReader.Create using a StreamReader. However, when MSBuild is calling itsXslTransform
task on a file in this type of path, and in the xsl file it calls theDocument
function on a file that also exists in a path like this, it will break. See details here: dotnet/msbuild#6863 (comment)This comment explains the issue. You hit an exception when calling the document function in an xslt file when that xslt file is under a path that contains private area unicode characters.
Xslt file example:
Place that next to a
b.xml
in a path that containsⅫㄨㄩ 啊阿鼾齄丂丄狚狛狜狝﨨﨩ˊˋ˙–⿻〇㐀㐁䶴䶵U1[]U2[]U3[]
.Configuration
Full framework & net core 6.0.100-preview.7.21379.14
Regression?
No
Other information
See original issue / MSBuild PR for in-depth notes.
The text was updated successfully, but these errors were encountered: