mirror of
https://github.com/restic/rest-server.git
synced 2025-12-06 17:15:45 -08:00
Minor cleanup and fixes
- Do not allow '.' as path component, because it undermines depth checks, and add tests - Fix GiB reporting - Fix metrics label - Helper function for http errors
This commit is contained in:
committed by
Alexander Neumann
parent
1f593fafaf
commit
d4cd47e503
14
repo/repo.go
14
repo/repo.go
@@ -165,14 +165,14 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
// getObject parses the URL path and returns the objectType and objectID,
|
||||
// if any. The objectID is optional.
|
||||
func (h *Handler) getObject(urlPath string) (objectType, objectID string) {
|
||||
if m := BlobPathRE.FindStringSubmatch(urlPath); len(m) > 0 {
|
||||
if len(m) == 2 || m[2] == "" {
|
||||
return m[1], ""
|
||||
}
|
||||
return m[1], m[2]
|
||||
} else {
|
||||
return "", ""
|
||||
m := BlobPathRE.FindStringSubmatch(urlPath)
|
||||
if len(m) == 0 {
|
||||
return "", "" // no match
|
||||
}
|
||||
if len(m) == 2 || m[2] == "" {
|
||||
return m[1], "" // no objectID
|
||||
}
|
||||
return m[1], m[2]
|
||||
}
|
||||
|
||||
// getSubPath returns the path for a file or subdir in the root of the repo.
|
||||
|
||||
Reference in New Issue
Block a user