mirror of
https://codeberg.org/VnPower/PixivFE
synced 2024-12-06 19:16:23 +01:00
Optimized CSRF regex
This commit is contained in:
+1
-3
@@ -5,7 +5,6 @@ import (
|
||||
"io"
|
||||
"net/http"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
session "codeberg.org/vnpower/pixivfe/v2/core/config"
|
||||
httpc "codeberg.org/vnpower/pixivfe/v2/core/http"
|
||||
@@ -42,8 +41,7 @@ func setToken(c *fiber.Ctx) error {
|
||||
|
||||
// CSRF token
|
||||
r := regexp.MustCompile(`"token":"([0-9a-f]+)"`)
|
||||
csrf := strings.Split(r.FindString(string(body)), ":")[1]
|
||||
csrf = csrf[1 : len(csrf)-1]
|
||||
csrf := r.FindStringSubmatch(string(body))[1]
|
||||
|
||||
if csrf == "" {
|
||||
return errors.New("Cannot authorize with supplied token.")
|
||||
|
||||
Reference in New Issue
Block a user