mirror of
https://github.com/Threnklyn/jira.git
synced 2026-05-24 06:48:26 +02:00
udpate deps
This commit is contained in:
+18
-2
@@ -4,13 +4,29 @@ import (
|
||||
"fmt"
|
||||
"os/exec"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
type osxProvider struct {
|
||||
}
|
||||
|
||||
var pwRe = regexp.MustCompile("password: \"(.+)\"")
|
||||
var pwRe = regexp.MustCompile(`password:\s+(?:0x[A-Fa-f0-9]+\s+)?"(.+)"`)
|
||||
|
||||
var escapeCodeRegexp = regexp.MustCompile(`\\([0-3][0-7]{2})`)
|
||||
|
||||
func unescapeOne(code []byte) []byte {
|
||||
i, _ := strconv.ParseUint(string(code[1:]), 8, 8)
|
||||
return []byte{byte(i)}
|
||||
}
|
||||
|
||||
func unescape(raw string) string {
|
||||
if !escapeCodeRegexp.MatchString(raw) {
|
||||
return raw
|
||||
} else {
|
||||
return string(escapeCodeRegexp.ReplaceAllFunc([]byte(raw), unescapeOne))
|
||||
}
|
||||
}
|
||||
|
||||
func (p osxProvider) Get(Service, Username string) (string, error) {
|
||||
args := []string{"find-generic-password",
|
||||
@@ -31,7 +47,7 @@ func (p osxProvider) Get(Service, Username string) (string, error) {
|
||||
if len(matches) != 2 {
|
||||
return "", ErrNotFound
|
||||
}
|
||||
return matches[1], nil
|
||||
return unescape(matches[1]), nil
|
||||
}
|
||||
|
||||
func (p osxProvider) Set(Service, Username, Password string) error {
|
||||
|
||||
Reference in New Issue
Block a user