Skip to content

Commit 7986985

Browse files
author
Jake Ginnivan
committed
Html Encoding step titles
1 parent 9bf03bb commit 7986985

3 files changed

Lines changed: 12 additions & 10 deletions

File tree

TestStack.BDDfy.Tests/Reporters/MarkDown/MarkDownReportBuilderTests.ShouldProduceExpectedMarkdownWithExamples.approved.txt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
**So that I can get money when the bank is closed**
55

66
### Example Scenario
7-
Given a <sign> account balance
7+
Given a &lt;sign&gt; account balance
88
When the account holder requests money
9-
Then money <action> dispensed
9+
Then money &lt;action&gt; dispensed
1010

1111
### Examples:
1212

13-
| sign | action | Result | Errors |
14-
| positive | is | Passed | |
15-
| negative | is not | Failed | Step: Then money <action> dispensed failed with exception: [Boom] [Details at 1 below] |
13+
| sign | action | Result | Errors |
14+
| positive | is | Passed | |
15+
| negative | is not | Failed | Step: Then money &lt;action&gt; dispensed failed with exception: [Boom] [Details at 1 below] |
1616

1717
#### Exceptions:
1818
1. Boom
@@ -24,9 +24,9 @@
2424
**So that I can be happy**
2525

2626
### Example Scenario
27-
Given a <sign> account balance
27+
Given a &lt;sign&gt; account balance
2828
When the account holder requests money
29-
Then money <action> dispensed
29+
Then money &lt;action&gt; dispensed
3030

3131
### Examples:
3232

TestStack.BDDfy.Tests/TestStack.BDDfy.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@
174174
<Content Include="Reporters\Html\ClassicReportBuilderTests.ShouldProduceExpectedHtmlWithExamples.approved.txt" />
175175
<Content Include="Reporters\Html\MetroReportBuilderTests.ShouldProduceExpectedHtmlWithExamples.approved.txt" />
176176
<Content Include="Reporters\MarkDown\MarkDownReportBuilderTests.ShouldProduceExpectedMarkdown.approved.txt" />
177+
<Content Include="Reporters\MarkDown\MarkDownReportBuilderTests.ShouldProduceExpectedMarkdownWithExamples.approved.txt" />
177178
<Content Include="Reporters\TextReporter\TextReporterTests.ShouldProduceExpectedMarkdownWithExamples.approved.txt" />
178179
<Content Include="Reporters\TextReporter\TextReporterTests.ShouldProduceExpectedReport.approved.txt" />
179180
</ItemGroup>

TestStack.BDDfy/Reporters/MarkDown/MarkDownReportBuilder.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Collections.Generic;
33
using System.Linq;
44
using System.Text;
5+
using System.Web;
56

67
namespace TestStack.BDDfy.Reporters.MarkDown
78
{
@@ -40,7 +41,7 @@ public string CreateReport(FileReportModel model)
4041
if (exampleScenario.Steps.Any())
4142
{
4243
foreach (var step in exampleScenario.Steps.Where(s => s.ShouldReport))
43-
report.AppendLine(" " + step.Title + " ");
44+
report.AppendLine(" " + HttpUtility.HtmlEncode(step.Title) + " ");
4445
}
4546

4647
report.AppendLine(); // separator
@@ -53,7 +54,7 @@ public string CreateReport(FileReportModel model)
5354
report.AppendLine(string.Format("### {0}", scenario.Title));
5455

5556
foreach (var step in scenario.Steps)
56-
report.AppendLine(" " + step.Title + " ");
57+
report.AppendLine(" " + HttpUtility.HtmlEncode(step.Title) + " ");
5758

5859
report.AppendLine(); // separator
5960
}
@@ -108,7 +109,7 @@ private void WriteExamples(StringBuilder report, Scenario exampleScenario, IEnum
108109
var failingStep = scenario.Steps.FirstOrDefault(s => s.Result == Result.Failed);
109110
var error = failingStep == null
110111
? null
111-
: string.Format("Step: {0} failed with exception: {1}", failingStep.Title, CreateExceptionMessage(failingStep));
112+
: string.Format("Step: {0} failed with exception: {1}", HttpUtility.HtmlEncode(failingStep.Title), CreateExceptionMessage(failingStep));
112113

113114
addRow(scenario.Example.Values.Select(e => e.GetValueAsString()), scenario.Result.ToString(), error);
114115
}

0 commit comments

Comments
 (0)