-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support inline rendering of CUSTOM_URL_SCHEMES (#8496)
* Support inline rendering of CUSTOM_URL_SCHEMES * Fix lint * Add tests * Fix lint
- Loading branch information
Showing
4 changed files
with
66 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -89,6 +89,11 @@ func TestRender_links(t *testing.T) { | |
} | ||
// Text that should be turned into URL | ||
|
||
defaultCustom := setting.Markdown.CustomURLSchemes | ||
setting.Markdown.CustomURLSchemes = []string{"ftp", "magnet"} | ||
ReplaceSanitizer() | ||
CustomLinkURLSchemes(setting.Markdown.CustomURLSchemes) | ||
|
||
test( | ||
"https://www.example.com", | ||
`<p><a href="https://www.example.com" rel="nofollow">https://www.example.com</a></p>`) | ||
|
@@ -131,6 +136,12 @@ func TestRender_links(t *testing.T) { | |
test( | ||
"https://username:[email protected]", | ||
`<p><a href="https://username:[email protected]" rel="nofollow">https://username:[email protected]</a></p>`) | ||
test( | ||
"ftp://gitea.com/file.txt", | ||
`<p><a href="ftp://gitea.com/file.txt" rel="nofollow">ftp://gitea.com/file.txt</a></p>`) | ||
test( | ||
"magnet:?xt=urn:btih:5dee65101db281ac9c46344cd6b175cdcadabcde&dn=download", | ||
`<p><a href="magnet:?xt=urn:btih:5dee65101db281ac9c46344cd6b175cdcadabcde&dn=download" rel="nofollow">magnet:?xt=urn:btih:5dee65101db281ac9c46344cd6b175cdcadabcde&dn=download</a></p>`) | ||
|
||
// Test that should *not* be turned into URL | ||
test( | ||
|
@@ -154,6 +165,14 @@ func TestRender_links(t *testing.T) { | |
test( | ||
"www", | ||
`<p>www</p>`) | ||
test( | ||
"ftps://gitea.com", | ||
`<p>ftps://gitea.com</p>`) | ||
|
||
// Restore previous settings | ||
setting.Markdown.CustomURLSchemes = defaultCustom | ||
ReplaceSanitizer() | ||
CustomLinkURLSchemes(setting.Markdown.CustomURLSchemes) | ||
} | ||
|
||
func TestRender_email(t *testing.T) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters