mirror of
				https://github.com/nkanaev/yarr.git
				synced 2025-10-30 06:31:07 +00:00 
			
		
		
		
	prevent route leak
This commit is contained in:
		| @@ -69,6 +69,10 @@ func unsafeMethod(method string) bool { | |||||||
| func (h Handler) ServeHTTP(rw http.ResponseWriter, req *http.Request) { | func (h Handler) ServeHTTP(rw http.ResponseWriter, req *http.Request) { | ||||||
| 	reqPath := req.URL.Path | 	reqPath := req.URL.Path | ||||||
| 	if BasePath != "" { | 	if BasePath != "" { | ||||||
|  | 		if !strings.HasPrefix(reqPath, BasePath) { | ||||||
|  | 			rw.WriteHeader(http.StatusNotFound) | ||||||
|  | 			return | ||||||
|  | 		} | ||||||
| 		reqPath = strings.TrimPrefix(req.URL.Path, BasePath) | 		reqPath = strings.TrimPrefix(req.URL.Path, BasePath) | ||||||
| 		if reqPath == "" { | 		if reqPath == "" { | ||||||
| 			http.Redirect(rw, req, BasePath+"/", http.StatusFound) | 			http.Redirect(rw, req, BasePath+"/", http.StatusFound) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user