diff --git a/html.go b/html.go index 182208d..1e6b434 100644 --- a/html.go +++ b/html.go @@ -168,10 +168,24 @@ func (options *Html) BlockHtml(out *bytes.Buffer, text []byte) { } doubleSpace(out) - out.Write(text) + if options.flags&HTML_SKIP_SCRIPT != 0 { + out.Write(stripTag(string(text), "script", "p")) + } else { + out.Write(text) + } out.WriteByte('\n') } +// This is a trivial implementation for the simplest possible case +func stripTag(text, tag, newTag string) []byte { + openTag := fmt.Sprintf("<%s>", tag) + closeTag := fmt.Sprintf("", tag) + openNewTag := fmt.Sprintf("<%s>", newTag) + closeNewTag := fmt.Sprintf("", newTag) + noOpen := strings.Replace(text, openTag, openNewTag, -1) + return []byte(strings.Replace(noOpen, closeTag, closeNewTag, -1)) +} + func (options *Html) HRule(out *bytes.Buffer) { doubleSpace(out) out.WriteString("alert()\n", "

alert()

\n", + + "\n", + "

alert()

\n", } doTestsInlineParam(t, tests, 0, HTML_SKIP_STYLE|HTML_SKIP_SCRIPT) }