mirror of
https://github.com/OpenListTeam/OpenList.git
synced 2025-09-19 04:06:18 +08:00
fix(share): support custom proxy url (#1130)
* feat(share): support custom proxy url * fix(share): count access * fix: maybe a path traversal vulnerability?
This commit is contained in:
@ -195,6 +195,7 @@ func SharingArchiveList(c *gin.Context, req *ArchiveListReq) {
|
||||
func SharingDown(c *gin.Context) {
|
||||
sid := c.Request.Context().Value(conf.SharingIDKey).(string)
|
||||
path := c.Request.Context().Value(conf.PathKey).(string)
|
||||
path = utils.FixAndCleanPath(path)
|
||||
pwd := c.Query("pwd")
|
||||
s, err := op.GetSharingById(sid)
|
||||
if err == nil {
|
||||
@ -219,6 +220,13 @@ func SharingDown(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
if setting.GetBool(conf.ShareForceProxy) || common.ShouldProxy(storage, stdpath.Base(actualPath)) {
|
||||
if _, ok := c.GetQuery("d"); !ok {
|
||||
if url := common.GenerateDownProxyURL(storage.GetStorage(), unwrapPath); url != "" {
|
||||
c.Redirect(302, url)
|
||||
_ = countAccess(c.ClientIP(), s)
|
||||
return
|
||||
}
|
||||
}
|
||||
link, obj, err := op.Link(c.Request.Context(), storage, actualPath, model.LinkArgs{
|
||||
Header: c.Request.Header,
|
||||
Type: c.Query("type"),
|
||||
@ -252,6 +260,7 @@ func SharingArchiveExtract(c *gin.Context) {
|
||||
}
|
||||
sid := c.Request.Context().Value(conf.SharingIDKey).(string)
|
||||
path := c.Request.Context().Value(conf.PathKey).(string)
|
||||
path = utils.FixAndCleanPath(path)
|
||||
pwd := c.Query("pwd")
|
||||
innerPath := utils.FixAndCleanPath(c.Query("inner"))
|
||||
archivePass := c.Query("pass")
|
||||
|
Reference in New Issue
Block a user