mirror of
https://github.com/restic/rest-server.git
synced 2025-10-19 07:33:21 +00: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:
parent
1f593fafaf
commit
d4cd47e503
5 changed files with 41 additions and 18 deletions
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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue