udpate deps

This commit is contained in:
Cory Bennett
2018-07-28 16:29:51 -07:00
parent 07ba74b34a
commit d16bcc2f51
237 changed files with 32346 additions and 10808 deletions
+18 -2
View File
@@ -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 {