summaryrefslogtreecommitdiff
path: root/vendor/github.com/russross/blackfriday/v2/esc.go
diff options
context:
space:
mode:
authorLibravatar Autumn! <86073772+autumnull@users.noreply.github.com>2022-12-16 11:20:22 +0000
committerLibravatar GitHub <noreply@github.com>2022-12-16 12:20:22 +0100
commiteb08529f35ce33ed98c34fb48013f0f4a5fc9635 (patch)
tree394fd774a943f5c33ce793c67b5865f2570b46c5 /vendor/github.com/russross/blackfriday/v2/esc.go
parent[bugfix] use match-sorter for filtering domain blocks (#1270) (diff)
downloadgotosocial-eb08529f35ce33ed98c34fb48013f0f4a5fc9635.tar.xz
[chore/bugfix] Switch markdown from blackfriday to goldmark (#1267)
Co-authored-by: Autumn! <autumnull@posteo.net>
Diffstat (limited to 'vendor/github.com/russross/blackfriday/v2/esc.go')
-rw-r--r--vendor/github.com/russross/blackfriday/v2/esc.go70
1 files changed, 0 insertions, 70 deletions
diff --git a/vendor/github.com/russross/blackfriday/v2/esc.go b/vendor/github.com/russross/blackfriday/v2/esc.go
deleted file mode 100644
index 6ab60102c..000000000
--- a/vendor/github.com/russross/blackfriday/v2/esc.go
+++ /dev/null
@@ -1,70 +0,0 @@
-package blackfriday
-
-import (
- "html"
- "io"
-)
-
-var htmlEscaper = [256][]byte{
- '&': []byte("&amp;"),
- '<': []byte("&lt;"),
- '>': []byte("&gt;"),
- '"': []byte("&quot;"),
-}
-
-func escapeHTML(w io.Writer, s []byte) {
- escapeEntities(w, s, false)
-}
-
-func escapeAllHTML(w io.Writer, s []byte) {
- escapeEntities(w, s, true)
-}
-
-func escapeEntities(w io.Writer, s []byte, escapeValidEntities bool) {
- var start, end int
- for end < len(s) {
- escSeq := htmlEscaper[s[end]]
- if escSeq != nil {
- isEntity, entityEnd := nodeIsEntity(s, end)
- if isEntity && !escapeValidEntities {
- w.Write(s[start : entityEnd+1])
- start = entityEnd + 1
- } else {
- w.Write(s[start:end])
- w.Write(escSeq)
- start = end + 1
- }
- }
- end++
- }
- if start < len(s) && end <= len(s) {
- w.Write(s[start:end])
- }
-}
-
-func nodeIsEntity(s []byte, end int) (isEntity bool, endEntityPos int) {
- isEntity = false
- endEntityPos = end + 1
-
- if s[end] == '&' {
- for endEntityPos < len(s) {
- if s[endEntityPos] == ';' {
- if entities[string(s[end:endEntityPos+1])] {
- isEntity = true
- break
- }
- }
- if !isalnum(s[endEntityPos]) && s[endEntityPos] != '&' && s[endEntityPos] != '#' {
- break
- }
- endEntityPos++
- }
- }
-
- return isEntity, endEntityPos
-}
-
-func escLink(w io.Writer, text []byte) {
- unesc := html.UnescapeString(string(text))
- escapeHTML(w, []byte(unesc))
-}