diff --git a/internal/reader/rewrite/rewriter_test.go b/internal/reader/rewrite/rewriter_test.go index 3910ccd4..fa2b765b 100644 --- a/internal/reader/rewrite/rewriter_test.go +++ b/internal/reader/rewrite/rewriter_test.go @@ -671,3 +671,35 @@ func TestAddHackerNewsLinksUsingOpener(t *testing.T) { t.Errorf(`Not expected output: got "%+v" instead of "%+v"`, testEntry, controlEntry) } } + +func TestAddImageTitle(t *testing.T) { + testEntry := &model.Entry{ + Title: `A title`, + Content: ` + + "onerror=alert(1) a=" + "onerror=alert(1) a=" + ;"onerror=alert(1) a=;" + pouf + pouf + pouf + `, + } + + controlEntry := &model.Entry{ + Title: `A title`, + Content: `

pouf

+

pouf

+

pouf

+
;"onerror=alert(1) a=;"

pouf

+
pouf

"onerror=alert(1) a="

+
pouf

"onerror=alert(1) a="

+
pouf

;"onerror=alert(1) a=;"

+ `, + } + Rewriter("https://example.org/article", testEntry, `add_image_title`) + + if !reflect.DeepEqual(testEntry, controlEntry) { + t.Errorf(`Not expected output: got "%+v" instead of "%+v"`, testEntry, controlEntry) + } +}