mirror of
				https://github.com/superseriousbusiness/gotosocial.git
				synced 2025-11-04 08:32:25 -06:00 
			
		
		
		
	Grand test fixup (#138)
* start fixing up tests * fix up tests + automate with drone * fiddle with linting * messing about with drone.yml * some more fiddling * hmmm * add cache * add vendor directory * verbose * ci updates * update some little things * update sig
This commit is contained in:
		
					parent
					
						
							
								329a5e8144
							
						
					
				
			
			
				commit
				
					
						98263a7de6
					
				
			
		
					 2677 changed files with 1090869 additions and 219 deletions
				
			
		
							
								
								
									
										70
									
								
								vendor/github.com/russross/blackfriday/v2/esc.go
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										70
									
								
								vendor/github.com/russross/blackfriday/v2/esc.go
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,70 @@
 | 
			
		|||
package blackfriday
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"html"
 | 
			
		||||
	"io"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
var htmlEscaper = [256][]byte{
 | 
			
		||||
	'&': []byte("&"),
 | 
			
		||||
	'<': []byte("<"),
 | 
			
		||||
	'>': []byte(">"),
 | 
			
		||||
	'"': []byte("""),
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
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))
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue