mirror of
https://github.com/go-gitea/gitea.git
synced 2026-10-08 20:43:24 +02:00
refactor: markup render (#38864)
1. add missing CSP header to api & web render endpoints. 2. make jupyter render skip post-processors, nothing to process 3. make ShortLinkProcessor correctly validate URL schemes and respect the CustomURLSchemes setting
This commit is contained in:
1 parent
eeeb5d7c7b
commit
938cde959e
25 files changed
+255
-172
No files matched your search
@@ -129,7 +129,8 @@ func TestExternalMarkupRenderer(t *testing.T) {
|
||||
req = NewRequest(t, "GET", "/user2/repo1/render/branch/master/bin.no-sanitizer")
|
||||
respSub := MakeRequest(t, req, http.StatusOK)
|
||||
assert.Equal(t, binaryContent, respSub.Body.String()) // raw content should keep the raw bytes (including invalid UTF-8 bytes), and no "external-render-iframe" helpers
|
||||
assert.Empty(t, respSub.Header().Get("Content-Security-Policy"), "sandbox is disabled by RENDER_CONTENT_SANDBOX")
|
||||
assert.NotContains(t, respSub.Header().Get("Content-Security-Policy"), "sandbox", "sandbox is disabled by RENDER_CONTENT_SANDBOX")
|
||||
assert.Contains(t, respSub.Header().Get("Content-Security-Policy"), "nonce-", "it should have the general policies as a normal web page")
|
||||
})
|
||||
|
||||
t.Run("HTMLContentWithExternalRenderIframeHelper", func(t *testing.T) {
|
||||
@@ -141,7 +142,8 @@ func TestExternalMarkupRenderer(t *testing.T) {
|
||||
`<script>foo("raw")</script>`,
|
||||
respSub.Body.String(),
|
||||
)
|
||||
assert.Empty(t, respSub.Header().Get("Content-Security-Policy"))
|
||||
assert.NotContains(t, respSub.Header().Get("Content-Security-Policy"), "sandbox")
|
||||
assert.Contains(t, respSub.Header().Get("Content-Security-Policy"), "nonce-")
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user