-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Add Xml default resolver parameter for XslCompiledTransform.Transform #8655
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
Changes from 3 commits
3089684
d053b00
0df29b6
b642163
8aa7767
a2b4f8f
ac6cd52
1d59a85
cf87ef1
b2803ab
0883df0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
using System.Xml; | ||
using System.Xml.XPath; | ||
using System.Xml.Xsl; | ||
using System.Text; | ||
using Microsoft.Build.Framework; | ||
using Microsoft.Build.Shared; | ||
using Microsoft.Build.Utilities; | ||
|
@@ -165,7 +166,7 @@ public override bool Execute() | |
{ | ||
using (XmlReader xr = xmlinput.CreateReader(i)) | ||
{ | ||
xslct.Transform(xr, arguments, xmlWriter); | ||
xslct.Transform(xr, arguments, xmlWriter, new XmlUrlResolver()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It feels weird to me to always pass the resolver, even when not trusted. I see though that it's also always passed to the constructors of the Should we pass it only when There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since .NET Core does not allow resolving external URIs for XML by default. So, add that default resolver explicitly. If the UseTrustedSettings is false, it won't allow the XSLT document() function. The XmlUrlResolver that resolves the document function won't work. |
||
} | ||
|
||
xmlWriter.Close(); | ||
|
@@ -174,7 +175,15 @@ public override bool Execute() | |
} | ||
catch (Exception e) when (!ExceptionHandling.IsCriticalException(e)) | ||
{ | ||
Log.LogErrorWithCodeFromResources("XslTransform.TransformError", e.Message); | ||
StringBuilder flattenedMessage = new StringBuilder(e.Message); | ||
Exception excep = e; | ||
while (excep.InnerException != null) | ||
{ | ||
excep = excep.InnerException; | ||
flattenedMessage.Append(" ---> ").Append(excep.Message); | ||
} | ||
Log.LogErrorWithCodeFromResources("XslTransform.TransformError", flattenedMessage.ToString()); | ||
Log.LogMessage(MessageImportance.Low, e.ToString()); | ||
JaynieBai marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return false; | ||
} | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.