Skip to content

Commit

Permalink
🐛 fix: jsonp wrong console.error usage
Browse files Browse the repository at this point in the history
  • Loading branch information
soxft committed Dec 4, 2024
1 parent d80e888 commit bceb7ca
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions app/controller/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,16 +141,16 @@ func JsonpHandler(c *gin.Context) {

callback := c.Query("callback")
if callback == "" {
c.String(200, "try{console.error(%s)}catch{}", "missing callback parameter")
c.String(200, "try{console.error('%s')}catch{}", "missing callback parameter")
return
}

u, err := url.Parse(c.GetHeader("Referer"))
if err != nil {
c.String(200, "try{console.error(%s)}catch{}", "unable to parse referer")
c.String(200, "try{console.error('%s')}catch{}", "unable to parse referer")
return
} else if u.Host == "" {
c.String(200, "try{console.error(%s)}catch{}", "invalid referer")
c.String(200, "try{console.error('%s')}catch{}", "invalid referer")
return
}

Expand All @@ -166,7 +166,7 @@ func JsonpHandler(c *gin.Context) {
}
jsonData, err := json.Marshal(data)
if err != nil {
c.String(200, "try{console.error(%s)}catch{}", "gen json failed")
c.String(200, "try{console.error('%s')}catch{}", "gen json failed")
return
}

Expand Down

0 comments on commit bceb7ca

Please sign in to comment.