diff options
author | Gusted <gusted@noreply.codeberg.org> | 2024-08-09 08:59:16 +0200 |
---|---|---|
committer | Gusted <gusted@noreply.codeberg.org> | 2024-08-09 08:59:16 +0200 |
commit | 4d0be867a22caccf38c1a776de5502a43dedcf02 (patch) | |
tree | 23a666289b13d265e43f05441a2410bf1c1751db | |
parent | Merge pull request 'i18n: backport of #4668 and #4783 to v8' (#4881) from 0ko... (diff) | |
parent | disallow javascript: URI in the repository description (diff) | |
download | forgejo-4d0be867a22caccf38c1a776de5502a43dedcf02.tar.xz forgejo-4d0be867a22caccf38c1a776de5502a43dedcf02.zip |
Merge pull request '[v8.0/forgejo] disallow javascript: URI in the repository description' (#4901) from bp-v8.0/forgejo-bb448f3 into v8.0/forgejov8.0.1
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/4901
Reviewed-by: 0ko <0ko@noreply.codeberg.org>
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
-rw-r--r-- | modules/markup/sanitizer.go | 1 | ||||
-rw-r--r-- | modules/markup/sanitizer_test.go | 5 |
2 files changed, 5 insertions, 1 deletions
diff --git a/modules/markup/sanitizer.go b/modules/markup/sanitizer.go index c0b449ea5b..d07bba3004 100644 --- a/modules/markup/sanitizer.go +++ b/modules/markup/sanitizer.go @@ -179,6 +179,7 @@ func createDefaultPolicy() *bluemonday.Policy { // repository descriptions. func createRepoDescriptionPolicy() *bluemonday.Policy { policy := bluemonday.NewPolicy() + policy.AllowStandardURLs() // Allow italics and bold. policy.AllowElements("i", "b", "em", "strong") diff --git a/modules/markup/sanitizer_test.go b/modules/markup/sanitizer_test.go index b7b8792bd7..163620c2ec 100644 --- a/modules/markup/sanitizer_test.go +++ b/modules/markup/sanitizer_test.go @@ -82,12 +82,15 @@ func TestDescriptionSanitizer(t *testing.T) { `<span class="emoji" aria-label="thumbs up">THUMBS UP</span>`, `<span class="emoji" aria-label="thumbs up">THUMBS UP</span>`, `<span style="color: red">Hello World</span>`, `<span>Hello World</span>`, `<br>`, ``, - `<a href="https://example.com" target="_blank" rel="noopener noreferrer">https://example.com</a>`, `<a href="https://example.com" target="_blank" rel="noopener noreferrer">https://example.com</a>`, + `<a href="https://example.com" target="_blank" rel="noopener noreferrer">https://example.com</a>`, `<a href="https://example.com" target="_blank" rel="noopener noreferrer nofollow">https://example.com</a>`, `<mark>Important!</mark>`, `Important!`, `<details>Click me! <summary>Nothing to see here.</summary></details>`, `Click me! Nothing to see here.`, `<input type="hidden">`, ``, `<b>I</b> have a <i>strong</i> <strong>opinion</strong> about <em>this</em>.`, `<b>I</b> have a <i>strong</i> <strong>opinion</strong> about <em>this</em>.`, `Provides alternative <code>wg(8)</code> tool`, `Provides alternative <code>wg(8)</code> tool`, + `<a href="javascript:alert('xss')">Click me</a>.`, `Click me.`, + `<a href="data:text/html,<script>alert('xss')</script>">Click me</a>.`, `Click me.`, + `<a href="vbscript:msgbox("xss")">Click me</a>.`, `Click me.`, } for i := 0; i < len(testCases); i += 2 { |