mirror of
https://github.com/actions/runner.git
synced 2025-12-11 04:46:58 +00:00
Fixed a bug where a misplaced = character could bypass heredoc-style processing. (#2627)
* Fixed a bug where a misplaced `=` character could bypass heredoc-style processing. Fixes https://github.com/github/c2c-actions/issues/6910 GitHub Docs for context: https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#multiline-strings * Consolidate near-identical FileCommand-related unit test classes. (#2672)
This commit is contained in:
committed by
GitHub
parent
c05e6748c3
commit
4ffd081aea
@@ -1,10 +1,21 @@
|
||||
using System.IO;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using Xunit;
|
||||
using GitHub.Runner.Sdk;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Linq;
|
||||
|
||||
namespace GitHub.Runner.Common.Tests
|
||||
{
|
||||
public enum LineEndingType
|
||||
{
|
||||
Native,
|
||||
Linux = 0x__0A,
|
||||
Windows = 0x0D0A
|
||||
}
|
||||
|
||||
public static class TestUtil
|
||||
{
|
||||
private const string Src = "src";
|
||||
@@ -41,5 +52,24 @@ namespace GitHub.Runner.Common.Tests
|
||||
Assert.True(Directory.Exists(testDataDir));
|
||||
return testDataDir;
|
||||
}
|
||||
|
||||
public static void WriteContent(string path, string content, LineEndingType lineEnding = LineEndingType.Native)
|
||||
{
|
||||
WriteContent(path, Enumerable.Repeat(content, 1), lineEnding);
|
||||
}
|
||||
|
||||
public static void WriteContent(string path, IEnumerable<string> content, LineEndingType lineEnding = LineEndingType.Native)
|
||||
{
|
||||
string newline = lineEnding switch
|
||||
{
|
||||
LineEndingType.Linux => "\n",
|
||||
LineEndingType.Windows => "\r\n",
|
||||
_ => Environment.NewLine,
|
||||
};
|
||||
var encoding = new UTF8Encoding(true); // Emit BOM
|
||||
var contentStr = string.Join(newline, content);
|
||||
File.WriteAllText(path, contentStr, encoding);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user