-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Initialize XmlReader Using A Stream #6847
Comments
Bug Triage Notes: Maybe we can add a unit test for XmlReaderExtension that runs with multi-byte characters and modify how the URI is created. There might be some setting in the constructor to explicitly look for multi-byte characters and it'll "just work" |
@tmeschter you've been investigating this quite a bit. If this currently works for us with no issues (loading a project with unicode characters should break the xmlreader but doesn't), do we need to worry about this eventually breaking for us? |
It's not all Unicode characters; it may be specific to characters from the Unicode private use area. I'm not sure the string the "Steps to Reproduce" will be enough to trigger it. Can you try Ⅻㄨㄩ 啊阿鼾齄丂丄狚狛狜狝﨨﨩ˊˋ˙–⿻〇㐀㐁䶴䶵U1[]U2[]U3[] instead? That's from the original bug. |
Oof, does this look familiar?
Very strange considering XmlReaderExtension creates a URI based off of the filepath. In theory this should be failing on project load, not during the XslTransformation task. I get this output trying to use XmlReader.Create using a StreamReader to the file.
What happens if I use the XmlReaderExtension in XslTransform?
Looks like the way XmlReaderExtension loads the URI is the proper way to load unicode characters.
Looks like we need to replace XmlReader.Create(new StreamReader(_data, new UTF8Encoding(encoderShouldEmitUTF8Identifier: false), detectEncodingFromByteOrderMarks: true)) Will get a PR up with this fix. Thanks! |
Yes, that's exactly the sort of issue error message I was seeing. |
Issue Description
See https://devdiv.visualstudio.com/DevDiv/_git/VS/pullrequest/349706.
When XmlReader.Create is called and a file path is passed in, it's converted to a URI under the hood. This can mangle multi-byte characters. The solution (in the link above) is to initialize the XmlReader using a stream to the file instead of the path alone.
Note this isn't an issue that we know of yet, the repro steps would fail if they were.
Steps to Reproduce
create dir with
啊阿鼾齄丂丄狚狛狜狝﨨﨩ˊˋ˙–⿻〇㐀㐁䶴䶵
as part of the pathdotnet new console -o proj
create transform.xslt in proj dir, copy contents from below
add foo target (below) to proj
msbuild proj
should see success
Foo target:
Build succeeds.
Analysis
This isn't an issue yet, but could be down the line.
Our code calls XmlReader.Create in two locations within the XslTransformation class which can be changed easily.
The complication comes from XmlReaderExtension, which initializes an XmlReader via
new XmlTextReader(...)
and a path is passed in. We should avoid this and call.Create()
passing in a stream, but this comment suggests that would be a breaking change:#4210 is something @ladipro had worked on so you might have a better idea of what to do here. Thoughts?
benvillalobos@6943a55 was my proposed fix before digging into #4210
The text was updated successfully, but these errors were encountered: