Skip to content

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

Merged
merged 11 commits into from
May 16, 2023
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/Shared/TaskLoggingHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,23 @@ public void LogMessageFromResources(MessageImportance importance, string message
#endif
}

/// <summary>
/// Flatten the inner exception message
/// </summary>
/// <param name="e">Exception to flatten.</param>
/// <returns></returns>
public static string GetInnerExceptionMessageString(Exception e)
{
StringBuilder flattenedMessage = new StringBuilder(e.Message);
Exception excep = e;
while (excep.InnerException != null)
{
excep = excep.InnerException;
flattenedMessage.Append(" ---> ").Append(excep.Message);
}
return flattenedMessage.ToString();
}

#endregion

#region ExternalProjectStarted/Finished logging methods
Expand Down
4 changes: 0 additions & 4 deletions src/Tasks.UnitTests/XslTransformation_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,10 @@ public sealed class XslTransformation_Tests
private readonly string _xslDocument = "<xsl:stylesheet version=\"1.0\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" xmlns:msxsl=\"urn:schemas-microsoft-com:xslt\" exclude-result-prefixes=\"msxsl\"><xsl:output method=\"xml\" indent=\"yes\"/><xsl:template match=\"@* | node()\"><surround><xsl:copy><xsl:apply-templates select=\"@* | node()\"/></xsl:copy></surround></xsl:template></xsl:stylesheet>";


#if FEATURE_COMPILED_XSL
/// <summary>
/// The contents of another xsl document for tests
/// </summary>
private readonly string _xslDocument2 = "<?xml version = \"1.0\" ?><xsl:stylesheet version=\"1.0\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\"><xsl:template match = \"myInclude\"><xsl:apply-templates select = \"document(@path)\"/></xsl:template><xsl:template match = \"@*|node()\"><xsl:copy><xsl:apply-templates select = \"@*|node()\"/></xsl:copy></xsl:template></xsl:stylesheet>";
#endif
/// <summary>
/// The contents of xslparameters for tests.
/// </summary>
Expand Down Expand Up @@ -1040,7 +1038,6 @@ public void MultipleXmlInputs_NotMatching()
CleanUp(dir);
}

#if FEATURE_COMPILED_XSL
/// <summary>
/// Validate that the XslTransformation task allows use of the document function
/// </summary>
Expand Down Expand Up @@ -1094,7 +1091,6 @@ public void XslDocumentFunctionWorks()

CleanUp(dir);
}
#endif

/// <summary>
/// Prepares the test environment, creates necessary files.
Expand Down
11 changes: 2 additions & 9 deletions src/Tasks/DownloadFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using System.IO;
using System.Net;
using System.Net.Http;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Build.Framework;
Expand Down Expand Up @@ -128,14 +127,8 @@ private async Task<bool> ExecuteAsync()
}
else
{
StringBuilder flattenedMessage = new StringBuilder(actualException.Message);
Exception excep = actualException;
while (excep.InnerException != null)
{
excep = excep.InnerException;
flattenedMessage.Append(" ---> ").Append(excep.Message);
}
Log.LogErrorWithCodeFromResources("DownloadFile.ErrorDownloading", SourceUrl, flattenedMessage.ToString());
string flattenedMessage = TaskLoggingHelper.GetInnerExceptionMessageString(e);
Log.LogErrorWithCodeFromResources("DownloadFile.ErrorDownloading", SourceUrl, flattenedMessage);
Log.LogMessage(MessageImportance.Low, actualException.ToString());
break;
}
Expand Down
3 changes: 3 additions & 0 deletions src/Tasks/Resources/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -2329,6 +2329,9 @@
</data>
<data name="XslTransform.UseTrustedSettings" xml:space="preserve">
<value>The usage of the document() method and embedded scripts is prohibited by default, due to risks of foreign code execution. If "{0}" is a trusted source that requires those constructs, please set the "UseTrustedSettings" parameter to "true" to allow their execution.</value>
</data>
<data name="XslTransform.SecuritySettingsViaUseTrustedSettings" xml:space="preserve">
<value>You are enabling relaxed XSLT security settings via UseTrustedSettings parameter. For more details on security implications of this settings please see https://aka.ms/msbuild/xsltransformation-task</value>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<value>You are enabling relaxed XSLT security settings via UseTrustedSettings parameter. For more details on security implications of this settings please see https://aka.ms/msbuild/xsltransformation-task</value>
<value>You are enabling relaxed XSLT security settings via the UseTrustedSettings parameter. For more details on security implications of this setting please see https://aka.ms/msbuild/xsltransformation-task</value>

</data>
<data name="XslTransform.PrecompiledXsltError" xml:space="preserve">
<value>MSB3705: XslCompiledDllPath is not supported when building with .NET Core.</value>
Expand Down
5 changes: 5 additions & 0 deletions src/Tasks/Resources/xlf/Strings.cs.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Tasks/Resources/xlf/Strings.de.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Tasks/Resources/xlf/Strings.es.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Tasks/Resources/xlf/Strings.fr.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Tasks/Resources/xlf/Strings.it.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Tasks/Resources/xlf/Strings.ja.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Tasks/Resources/xlf/Strings.ko.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Tasks/Resources/xlf/Strings.pl.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Tasks/Resources/xlf/Strings.pt-BR.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Tasks/Resources/xlf/Strings.ru.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Tasks/Resources/xlf/Strings.tr.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Tasks/Resources/xlf/Strings.zh-Hans.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Tasks/Resources/xlf/Strings.zh-Hant.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading