Implementing custom PathClean function to allow masking, closes #1298 (#1317)

* Added path cleanup functions with masking to preserve certain patterns + unit tests, #1298

* Use custom PathClean function instead of path.Clean to apply masks to preserve protocol separator in the path

* Indentation corrected in the test data map to pass the lint

* Fixing ineffassign of a temporary string variable

* Improved variable naming and documentation

* Improved variable naming

* Added benchmarks and improved variable naming in tests

* Removed unnecessary value capture when iterating over a map for keys

* A typo correction
This commit is contained in:
Sawood Alam
2016-12-31 22:29:14 -05:00
committed by Matt Holt
parent 7cbbb01f94
commit 04bee0f36d
3 changed files with 197 additions and 2 deletions

View File

@@ -9,7 +9,6 @@ import (
"net"
"net/http"
"os"
"path"
"runtime"
"strings"
"sync"
@@ -351,7 +350,7 @@ func sanitizePath(r *http.Request) {
if r.URL.Path == "/" {
return
}
cleanedPath := path.Clean(r.URL.Path)
cleanedPath := CleanPath(r.URL.Path)
if cleanedPath == "." {
r.URL.Path = "/"
} else {