Skip to content

Commit

Permalink
fix: page crashes if ipa name contains chinese (close #1712)
Browse files Browse the repository at this point in the history
  • Loading branch information
xhofe committed Sep 19, 2022
1 parent 2185839 commit d6d82c3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
23 changes: 17 additions & 6 deletions server/handles/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,32 @@ func Favicon(c *gin.Context) {
}

func Plist(c *gin.Context) {
link := c.Param("link")
u, err := utils.SafeAtob(link)
linkNameB64 := strings.TrimSuffix(c.Param("link_name"), ".plist")
linkName, err := utils.SafeAtob(linkNameB64)
if err != nil {
common.ErrorResp(c, err, 400)
return
}
uUrl, err := url.Parse(u)
linkNameSplit := strings.Split(linkName, "/")
if len(linkNameSplit) != 2 {
common.ErrorStrResp(c, "malformed link", 400)
return
}
linkEncode := linkNameSplit[0]
linkStr, err := url.PathUnescape(linkEncode)
if err != nil {
common.ErrorResp(c, err, 400)
return
}
link, err := url.Parse(linkStr)
if err != nil {
common.ErrorResp(c, err, 400)
return
}
fullName := c.Param("name")
Url := uUrl.String()
fullName = strings.TrimSuffix(fullName, ".plist")
fullName, err = utils.SafeAtob(fullName)
Url := link.String()
nameEncode := linkNameSplit[1]
fullName, err = url.PathUnescape(nameEncode)
if err != nil {
common.ErrorResp(c, err, 400)
return
Expand Down
2 changes: 1 addition & 1 deletion server/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func Init(r *gin.Engine) {
WebDav(r.Group("/dav"))

r.GET("/favicon.ico", handles.Favicon)
r.GET("/i/:link/:name", handles.Plist)
r.GET("/i/:link_name", handles.Plist)
r.GET("/d/*path", middlewares.Down, handles.Down)
r.GET("/p/*path", middlewares.Down, handles.Proxy)

Expand Down

0 comments on commit d6d82c3

Please sign in to comment.