mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-05-30 21:46:21 +00:00
fix(volume): avoid panic when URL path has a dot before the comma (#9712)
LastIndex returns -1 when the separator is missing and can return any position when both are present. A path like /vol/file.jpg,abc gives dotSep<commaSep, so path[commaSep+1:dotSep] slices with start>end and panics. Only treat the dot as an extension boundary when it sits after the comma.
This commit is contained in:
@@ -110,7 +110,8 @@ func CreateNeedleFromRequest(r *http.Request, fixJpgOrientation bool, sizeLimit
|
||||
commaSep := strings.LastIndex(r.URL.Path, ",")
|
||||
dotSep := strings.LastIndex(r.URL.Path, ".")
|
||||
fid := r.URL.Path[commaSep+1:]
|
||||
if dotSep > 0 {
|
||||
// dot must be after comma; otherwise path[commaSep+1:dotSep] panics
|
||||
if dotSep > commaSep {
|
||||
fid = r.URL.Path[commaSep+1 : dotSep]
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user