mirror of
				https://github.com/caddyserver/caddy.git
				synced 2025-10-31 10:37:24 -04:00 
			
		
		
		
	Added escaped versions of uri, query and path.
This commit is contained in:
		
							parent
							
								
									c748ef944b
								
							
						
					
					
						commit
						168723a026
					
				| @ -3,6 +3,7 @@ package middleware | |||||||
| import ( | import ( | ||||||
| 	"net" | 	"net" | ||||||
| 	"net/http" | 	"net/http" | ||||||
|  | 	"net/url" | ||||||
| 	"path" | 	"path" | ||||||
| 	"strconv" | 	"strconv" | ||||||
| 	"strings" | 	"strings" | ||||||
| @ -38,11 +39,13 @@ func NewReplacer(r *http.Request, rr *responseRecorder, emptyValue string) Repla | |||||||
| 				} | 				} | ||||||
| 				return "http" | 				return "http" | ||||||
| 			}(), | 			}(), | ||||||
| 			"{host}":     r.Host, | 			"{host}":          r.Host, | ||||||
| 			"{path}":     r.URL.Path, | 			"{path}":          r.URL.Path, | ||||||
| 			"{query}":    r.URL.RawQuery, | 			"{path_escaped}":  url.QueryEscape(r.URL.Path), | ||||||
| 			"{fragment}": r.URL.Fragment, | 			"{query}":         r.URL.RawQuery, | ||||||
| 			"{proto}":    r.Proto, | 			"{query_escaped}": url.QueryEscape(r.URL.RawQuery), | ||||||
|  | 			"{fragment}":      r.URL.Fragment, | ||||||
|  | 			"{proto}":         r.Proto, | ||||||
| 			"{remote}": func() string { | 			"{remote}": func() string { | ||||||
| 				if fwdFor := r.Header.Get("X-Forwarded-For"); fwdFor != "" { | 				if fwdFor := r.Header.Get("X-Forwarded-For"); fwdFor != "" { | ||||||
| 					return fwdFor | 					return fwdFor | ||||||
| @ -60,7 +63,8 @@ func NewReplacer(r *http.Request, rr *responseRecorder, emptyValue string) Repla | |||||||
| 				} | 				} | ||||||
| 				return port | 				return port | ||||||
| 			}(), | 			}(), | ||||||
| 			"{uri}": r.URL.RequestURI(), | 			"{uri}":         r.URL.RequestURI(), | ||||||
|  | 			"{uri_escaped}": url.QueryEscape(r.URL.RequestURI()), | ||||||
| 			"{when}": func() string { | 			"{when}": func() string { | ||||||
| 				return time.Now().Format(timeFormat) | 				return time.Now().Format(timeFormat) | ||||||
| 			}(), | 			}(), | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user