Skip to content

Commit e62e675

Browse files
committed
fix
1 parent 2d4f88c commit e62e675

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

modules/markup/camo.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
package markup
66

77
import (
8-
"bytes"
98
"crypto/hmac"
109
"crypto/sha1"
1110
"encoding/base64"
@@ -16,18 +15,17 @@ import (
1615
)
1716

1817
// CamoEncode encodes a lnk to fit with the go-camo and camo proxy links
19-
func CamoEncode(link []byte) []byte {
20-
if bytes.HasPrefix(link, []byte(setting.CamoServerURL)) || len(setting.CamoHMACKey) == 0 {
18+
func CamoEncode(link string) string {
19+
if strings.HasPrefix(link, setting.CamoServerURL) || len(setting.CamoHMACKey) == 0 {
2120
return link
2221
}
2322

24-
hmacKey := []byte(setting.CamoHMACKey)
25-
mac := hmac.New(sha1.New, hmacKey)
26-
_, _ = mac.Write(link) // hmac does not return errors
23+
mac := hmac.New(sha1.New, []byte(setting.CamoHMACKey))
24+
_, _ = mac.Write([]byte(link)) // hmac does not return errors
2725
macSum := b64encode(mac.Sum(nil))
28-
encodedURL := b64encode(link)
26+
encodedURL := b64encode([]byte(link))
2927

30-
return []byte(util.URLJoin(setting.CamoServerURL, macSum, encodedURL))
28+
return util.URLJoin(setting.CamoServerURL, macSum, encodedURL)
3129
}
3230

3331
func b64encode(data []byte) string {

0 commit comments

Comments
 (0)