Skip to content
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

Fix regression from #315 #340

Merged
merged 1 commit into from May 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -7,6 +7,7 @@
*.userosscache
*.sln.docstates
*.nuget.props
*.nuget.targets

# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
Expand Down
3 changes: 3 additions & 0 deletions changelog.md
@@ -1,5 +1,8 @@
# Changelog

## WIP
- Fix regression when escaping HTML characters ([(PR #340)](https://github.com/lunet-io/markdig/pull/340))

## 0.17.0 (10 May 2019)
- Update to latest CommonMark specs 0.29 ([(PR #327)](https://github.com/lunet-io/markdig/pull/327))
- Add `AutoLinkOptions` with `OpenInNewWindow`, `UseHttpsForWWWLinks` ([(PR #327)](https://github.com/lunet-io/markdig/pull/327))
Expand Down
8 changes: 8 additions & 0 deletions src/Markdig.Tests/MiscTests.cs
Expand Up @@ -8,6 +8,14 @@ namespace Markdig.Tests
{
public class MiscTests
{
[Test]
public void TestAltTextIsCorrectlyEscaped()
{
TestParser.TestSpec(
@"![This is image alt text with quotation ' and double quotation ""hello"" world](girl.png)",
@"<p><img src=""girl.png"" alt=""This is image alt text with quotation ' and double quotation &quot;hello&quot; world"" /></p>");
}

[Test]
public void TestChangelogPRLinksMatchDescription()
{
Expand Down
3 changes: 2 additions & 1 deletion src/Markdig/Markdown.cs
Expand Up @@ -184,7 +184,8 @@ public static MarkdownDocument ToPlainText(string markdown, TextWriter writer, M
var renderer = new HtmlRenderer(writer)
{
EnableHtmlForBlock = false,
EnableHtmlForInline = false
EnableHtmlForInline = false,
EnableHtmlEscape = false,
};
pipeline.Setup(renderer);

Expand Down
Expand Up @@ -13,7 +13,7 @@ public class HtmlEntityInlineRenderer : HtmlObjectRenderer<HtmlEntityInline>
{
protected override void Write(HtmlRenderer renderer, HtmlEntityInline obj)
{
if (renderer.EnableHtmlForInline)
if (renderer.EnableHtmlEscape)
{
renderer.WriteEscape(obj.Transcoded);
}
Expand Down
6 changes: 3 additions & 3 deletions src/Markdig/Renderers/Html/Inlines/LiteralInlineRenderer.cs
Expand Up @@ -13,13 +13,13 @@ public class LiteralInlineRenderer : HtmlObjectRenderer<LiteralInline>
{
protected override void Write(HtmlRenderer renderer, LiteralInline obj)
{
if (renderer.EnableHtmlForInline)
if (renderer.EnableHtmlEscape)
{
renderer.WriteEscape(obj.Content);
renderer.WriteEscape(ref obj.Content);
}
else
{
renderer.Write(obj.Content);
renderer.Write(ref obj.Content);
}
}
}
Expand Down