mirror of
				https://github.com/superseriousbusiness/gotosocial.git
				synced 2025-10-31 04:12:25 -05:00 
			
		
		
		
	[chore] add back exif-terminator and use only for jpeg,png,webp (#3161)
* add back exif-terminator and use only for jpeg,png,webp * fix arguments passed to terminateExif() * pull in latest exif-terminator * fix test * update processed img --------- Co-authored-by: tobi <tobi.smethurst@protonmail.com>
This commit is contained in:
		
					parent
					
						
							
								7b5917d6ae
							
						
					
				
			
			
				commit
				
					
						94e87610c4
					
				
			
		
					 191 changed files with 38772 additions and 58 deletions
				
			
		
							
								
								
									
										56
									
								
								vendor/github.com/go-xmlfmt/xmlfmt/xmlfmt.go
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										56
									
								
								vendor/github.com/go-xmlfmt/xmlfmt/xmlfmt.go
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1,56 @@ | |||
| //////////////////////////////////////////////////////////////////////////// | ||||
| // Porgram: xmlfmt.go | ||||
| // Purpose: Go XML Beautify from XML string using pure string manipulation | ||||
| // Authors: Antonio Sun (c) 2016-2019, All rights reserved | ||||
| //////////////////////////////////////////////////////////////////////////// | ||||
| 
 | ||||
| package xmlfmt | ||||
| 
 | ||||
| import ( | ||||
| 	"regexp" | ||||
| 	"strings" | ||||
| ) | ||||
| 
 | ||||
| var ( | ||||
| 	reg = regexp.MustCompile(`<([/!]?)([^>]+?)(/?)>`) | ||||
| 	// NL is the newline string used in XML output, define for DOS-convenient. | ||||
| 	NL = "\r\n" | ||||
| ) | ||||
| 
 | ||||
| // FormatXML will (purly) reformat the XML string in a readable way, without any rewriting/altering the structure | ||||
| func FormatXML(xmls, prefix, indent string) string { | ||||
| 	src := regexp.MustCompile(`(?s)>\s+<`).ReplaceAllString(xmls, "><") | ||||
| 
 | ||||
| 	rf := replaceTag(prefix, indent) | ||||
| 	return (prefix + reg.ReplaceAllStringFunc(src, rf)) | ||||
| } | ||||
| 
 | ||||
| // replaceTag returns a closure function to do 's/(?<=>)\s+(?=<)//g; s(<(/?)([^>]+?)(/?)>)($indent+=$3?0:$1?-1:1;"<$1$2$3>"."\n".("  "x$indent))ge' as in Perl | ||||
| // and deal with comments as well | ||||
| func replaceTag(prefix, indent string) func(string) string { | ||||
| 	indentLevel := 0 | ||||
| 	return func(m string) string { | ||||
| 		// head elem | ||||
| 		if strings.HasPrefix(m, "<?xml") { | ||||
| 			return NL + prefix + strings.Repeat(indent, indentLevel) + m | ||||
| 		} | ||||
| 		// empty elem | ||||
| 		if strings.HasSuffix(m, "/>") { | ||||
| 			return NL + prefix + strings.Repeat(indent, indentLevel) + m | ||||
| 		} | ||||
| 		// comment elem | ||||
| 		if strings.HasPrefix(m, "<!") { | ||||
| 			return NL + prefix + strings.Repeat(indent, indentLevel) + m | ||||
| 		} | ||||
| 		// end elem | ||||
| 		if strings.HasPrefix(m, "</") { | ||||
| 			indentLevel-- | ||||
| 			return NL + prefix + strings.Repeat(indent, indentLevel) + m | ||||
| 		} | ||||
| 		defer func() { | ||||
| 			indentLevel++ | ||||
| 		}() | ||||
| 
 | ||||
| 		return NL + prefix + strings.Repeat(indent, indentLevel) + m | ||||
| 	} | ||||
| } | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue