From 7e9a57463ff1634bca3967415fb5c6e841eb8c3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vytautas=20=C5=A0altenis?= Date: Tue, 5 Apr 2016 12:13:37 +0300 Subject: [PATCH] Implement SkipStyle, add test Fix a bug in findHtmlTagPos introduced with e02c392d. --- html.go | 5 ++++- inline_test.go | 9 +++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/html.go b/html.go index 260033e..754213e 100644 --- a/html.go +++ b/html.go @@ -884,7 +884,7 @@ func findHtmlTagPos(tag []byte, tagname string) (bool, int) { } rightAngle := skipUntilCharIgnoreQuotes(tag, i, '>') - if rightAngle > i { + if rightAngle >= i { return true, rightAngle } @@ -1133,6 +1133,9 @@ func (r *HTML) RenderNode(w io.Writer, node *Node, entering bool) WalkStatus { r.out(w, tag("/del", nil, false)) } case HTMLSpan: + if r.flags&SkipStyle != 0 && isHtmlTag(node.Literal, "style") { + break + } //if options.safe { // out(w, "") //} else { diff --git a/inline_test.go b/inline_test.go index 28ff283..0d10ff5 100644 --- a/inline_test.go +++ b/inline_test.go @@ -1139,6 +1139,15 @@ func TestSkipImages(t *testing.T) { }) } +func TestSkipStyle(t *testing.T) { + doTestsInlineParam(t, []string{ + "foo\n\n bar", + "

foo

\n\n

color: #f00 bar

\n", + }, TestParams{ + HTMLFlags: SkipStyle, + }) +} + func TestUseXHTML(t *testing.T) { doTestsParam(t, []string{ "---",