Import Anubis v1.28.2
Replace the tree with upstream TecharoHQ/anubis v1.28.2 (a1384fbf42e3). Masyunis customizations are re-applied in the following commits.
This commit is contained in:
1 parent
eb3e46d8d0
commit
e07de898cd
573 files changed
+35846
-6807
No files matched your search
@@ -0,0 +1,20 @@
|
||||
package challengepage
|
||||
|
||||
import (
|
||||
"html"
|
||||
"regexp"
|
||||
)
|
||||
|
||||
//go:generate go tool github.com/a-h/templ/cmd/templ generate
|
||||
|
||||
// wikipediaLink matches an escaped Wikipedia anchor tag in translated text.
|
||||
// The URL character set is restricted so that nothing in it can break out of
|
||||
// the href attribute.
|
||||
var wikipediaLink = regexp.MustCompile(`<a href="(https://[a-z-]{2,12}\.wikipedia\.org/wiki/[A-Za-z0-9_-]+)">(.*?)</a>`)
|
||||
|
||||
// explanationHTML escapes translated text and then restores only anchor tags
|
||||
// pointing at Wikipedia. Translations are community-contributed, so they must
|
||||
// never be rendered as raw HTML.
|
||||
func explanationHTML(text string) string {
|
||||
return wikipediaLink.ReplaceAllString(html.EscapeString(text), `<a href="$1">$2</a>`)
|
||||
}
|
||||
Reference in new issue
Block a user