Skip to content

Commit bc97a25

Browse files
hshpyILoveScratch2xrgzs
authored andcommitted
fix(security): potential XSS vulnerabilities (#880)
* fix(security): potential XSS vulnerabilities * chore: replace alist identifier to openlist identifier Co-authored-by: MadDogOwner <[email protected]> Signed-off-by: ILoveScratch <[email protected]> --------- Signed-off-by: ILoveScratch <[email protected]> Co-authored-by: ILoveScratch <[email protected]> Co-authored-by: MadDogOwner <[email protected]>
1 parent a50ee32 commit bc97a25

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

server/handles/helper.go

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package handles
22

33
import (
44
"fmt"
5+
"html"
56
"net/url"
67
"strings"
78

@@ -43,27 +44,24 @@ func Plist(c *gin.Context) {
4344
common.ErrorResp(c, err, 400)
4445
return
4546
}
46-
fullName := c.Param("name")
47-
Url := link.String()
48-
Url = strings.ReplaceAll(Url, "<", "[")
49-
Url = strings.ReplaceAll(Url, ">", "]")
5047
nameEncode := linkNameSplit[1]
51-
fullName, err = url.PathUnescape(nameEncode)
48+
fullName, err := url.PathUnescape(nameEncode)
5249
if err != nil {
5350
common.ErrorResp(c, err, 400)
5451
return
5552
}
5653
name := fullName
57-
identifier := fmt.Sprintf("ci.nn.%s", url.PathEscape(fullName))
58-
sep := "@"
59-
if strings.Contains(fullName, sep) {
60-
ss := strings.Split(fullName, sep)
61-
name = strings.Join(ss[:len(ss)-1], sep)
54+
identifier := fmt.Sprintf("org.oplist.%s", fullName)
55+
if strings.Contains(fullName, "@") {
56+
ss := strings.Split(fullName, "@")
57+
name = strings.Join(ss[:len(ss)-1], "@")
6258
identifier = ss[len(ss)-1]
6359
}
64-
65-
name = strings.ReplaceAll(name, "<", "[")
66-
name = strings.ReplaceAll(name, ">", "]")
60+
Url := link.String()
61+
Url = strings.ReplaceAll(Url, "<", "&lt;")
62+
Url = strings.ReplaceAll(Url, ">", "&gt;")
63+
name = html.EscapeString(name)
64+
identifier = html.EscapeString(identifier)
6765
plist := fmt.Sprintf(`<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
6866
<plist version="1.0">
6967
<dict>

0 commit comments

Comments
 (0)