code.gitea.io/gitea@v1.21.7/tests/integration/view_test.go (about) 1 // Copyright 2020 The Gitea Authors. All rights reserved. 2 // SPDX-License-Identifier: MIT 3 4 package integration 5 6 import ( 7 "net/http" 8 "testing" 9 10 "code.gitea.io/gitea/tests" 11 12 "github.com/stretchr/testify/assert" 13 ) 14 15 func TestRenderFileSVGIsInImgTag(t *testing.T) { 16 defer tests.PrepareTestEnv(t)() 17 18 session := loginUser(t, "user2") 19 20 req := NewRequest(t, "GET", "/user2/repo2/src/branch/master/line.svg") 21 resp := session.MakeRequest(t, req, http.StatusOK) 22 23 doc := NewHTMLParser(t, resp.Body) 24 src, exists := doc.doc.Find(".file-view img").Attr("src") 25 assert.True(t, exists, "The SVG image should be in an <img> tag so that scripts in the SVG are not run") 26 assert.Equal(t, "/user2/repo2/raw/branch/master/line.svg", src) 27 }