Skip to content

Commit

Permalink
clean url path; check that ht:// configured prior to redirecting
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Aizman <[email protected]>
  • Loading branch information
alex-aizman committed Dec 18, 2024
1 parent 576ce3c commit 4480026
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 7 additions & 1 deletion ais/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -3038,8 +3038,14 @@ func (p *proxy) rootHandler(w http.ResponseWriter, r *http.Request) {
}

// by default, s3 is serviced at `/s3`
// with `/` root reserved for vanilla http locations via ht:// mechanism
if !cmn.Rom.Features().IsSet(feat.S3APIviaRoot) {
config := cmn.GCO.Get()
if config.Backend.Get(apc.HT) == nil {
p.writeErrURL(w, r)
return
}

// `/` root reserved for vanilla http locations via ht:// mechanism
p.htHandler(w, r)
return
}
Expand Down
8 changes: 5 additions & 3 deletions cmn/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,15 @@ func MakeRangeHdr(start, length int64) string {
const maxItems = 1000

func ParseURL(path string, itemsPresent []string, itemsAfter int, splitAfter bool) ([]string, error) {
// path.Clean(string) reduced to this:
for path != "" && path[0] == '/' {
path = path[1:]
}

var (
split []string
l = len(itemsPresent)
)
if path != "" && path[0] == '/' {
path = path[1:] // remove leading slash
}
if splitAfter {
split = strings.SplitN(path, "/", maxItems)
} else {
Expand Down

0 comments on commit 4480026

Please sign in to comment.