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:
John Wesley Walker III
2023-06-29 12:52:05 +02:00
committed by GitHub
parent c05e6748c3
commit 4ffd081aea
7 changed files with 659 additions and 1008 deletions

View File

@@ -124,7 +124,7 @@ namespace GitHub.Runner.Common.Tests.Worker
"",
"## This is more markdown content",
};
WriteContent(stepSummaryFile, content);
TestUtil.WriteContent(stepSummaryFile, content);
_createStepCommand.ProcessCommand(_executionContext.Object, stepSummaryFile, null);
_jobExecutionContext.Complete();
@@ -153,7 +153,7 @@ namespace GitHub.Runner.Common.Tests.Worker
"",
"# GITHUB_TOKEN ghs_verysecuretoken",
};
WriteContent(stepSummaryFile, content);
TestUtil.WriteContent(stepSummaryFile, content);
_createStepCommand.ProcessCommand(_executionContext.Object, stepSummaryFile, null);
@@ -167,21 +167,6 @@ namespace GitHub.Runner.Common.Tests.Worker
}
}
private void WriteContent(
string path,
List<string> content,
string newline = null)
{
if (string.IsNullOrEmpty(newline))
{
newline = Environment.NewLine;
}
var encoding = new UTF8Encoding(true); // Emit BOM
var contentStr = string.Join(newline, content);
File.WriteAllText(path, contentStr, encoding);
}
private TestHostContext Setup([CallerMemberName] string name = "")
{
var hostContext = new TestHostContext(this, name);