Skip to content

Commit 14bf4ec

Browse files
authored
fix(share): support custom proxy url (#1130)
* feat(share): support custom proxy url * fix(share): count access * fix: maybe a path traversal vulnerability?
1 parent 04a5e58 commit 14bf4ec

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

server/handles/sharing.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ func SharingArchiveList(c *gin.Context, req *ArchiveListReq) {
195195
func SharingDown(c *gin.Context) {
196196
sid := c.Request.Context().Value(conf.SharingIDKey).(string)
197197
path := c.Request.Context().Value(conf.PathKey).(string)
198+
path = utils.FixAndCleanPath(path)
198199
pwd := c.Query("pwd")
199200
s, err := op.GetSharingById(sid)
200201
if err == nil {
@@ -219,6 +220,13 @@ func SharingDown(c *gin.Context) {
219220
return
220221
}
221222
if setting.GetBool(conf.ShareForceProxy) || common.ShouldProxy(storage, stdpath.Base(actualPath)) {
223+
if _, ok := c.GetQuery("d"); !ok {
224+
if url := common.GenerateDownProxyURL(storage.GetStorage(), unwrapPath); url != "" {
225+
c.Redirect(302, url)
226+
_ = countAccess(c.ClientIP(), s)
227+
return
228+
}
229+
}
222230
link, obj, err := op.Link(c.Request.Context(), storage, actualPath, model.LinkArgs{
223231
Header: c.Request.Header,
224232
Type: c.Query("type"),
@@ -252,6 +260,7 @@ func SharingArchiveExtract(c *gin.Context) {
252260
}
253261
sid := c.Request.Context().Value(conf.SharingIDKey).(string)
254262
path := c.Request.Context().Value(conf.PathKey).(string)
263+
path = utils.FixAndCleanPath(path)
255264
pwd := c.Query("pwd")
256265
innerPath := utils.FixAndCleanPath(c.Query("inner"))
257266
archivePass := c.Query("pass")

0 commit comments

Comments
 (0)