Skip to content

Commit

Permalink
fix: use base64 encode for ipa install
Browse files Browse the repository at this point in the history
  • Loading branch information
xhofe committed Sep 17, 2022
1 parent bec3a32 commit d436a6e
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions server/handles/helper.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package handles

import (
"encoding/base64"
"fmt"
"net/url"
"strings"
Expand All @@ -16,21 +17,30 @@ func Favicon(c *gin.Context) {
c.Redirect(302, setting.GetStr(conf.Favicon))
}

var DEC = map[string]string{
"-": "+",
"_": "/",
".": "=",
}

func Plist(c *gin.Context) {
link := c.Param("link")
u, err := url.PathUnescape(link)
for k, v := range DEC {
link = strings.ReplaceAll(link, k, v)
}
u, err := base64.StdEncoding.DecodeString(link)
if err != nil {
common.ErrorResp(c, err, 500)
return
}
uUrl, err := url.Parse(u)
uUrl, err := url.Parse(string(u))
if err != nil {
common.ErrorResp(c, err, 500)
return
}
name := c.Param("name")
log.Debug("name", name)
u = uUrl.String()
Url := uUrl.String()
name = strings.TrimSuffix(name, ".plist")
name = strings.ReplaceAll(name, "<", "[")
name = strings.ReplaceAll(name, ">", "]")
Expand Down Expand Up @@ -63,7 +73,7 @@ func Plist(c *gin.Context) {
</dict>
</array>
</dict>
</plist>`, u, url.PathEscape(name), name)
</plist>`, Url, url.PathEscape(name), name)
c.Header("Content-Type", "application/xml;charset=utf-8")
c.Status(200)
_, _ = c.Writer.WriteString(plist)
Expand Down

0 comments on commit d436a6e

Please sign in to comment.