Skip to content

Commit

Permalink
move stuff around and use the right API for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
songgao authored and cjb committed Oct 14, 2019
1 parent 196f401 commit 3592f81
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
6 changes: 2 additions & 4 deletions go/chat/attachments/downloader.go
Expand Up @@ -5,7 +5,6 @@ import (
"fmt"
"io"
"os"
"path"

"github.com/keybase/client/go/chat/globals"
"github.com/keybase/client/go/libkb"
Expand Down Expand Up @@ -38,9 +37,8 @@ func SinkFromFilename(ctx context.Context, g *globals.Context, uid gregor1.UID,
if err != nil || typ != chat1.MessageType_ATTACHMENT {
return "", nil, fmt.Errorf("invalid message type for download: %v", typ)
}
basepath := body.Attachment().Object.Filename
basename := path.Base(basepath)
safeBasename := libkb.GetSafeFilename(basename)
unsafeBasename := body.Attachment().Object.Filename
safeBasename := libkb.GetSafeFilename(unsafeBasename)

filePath, err := libkb.FindFilePathWithNumberSuffix(parentDir, safeBasename, useArbitraryName)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions go/libkb/util.go
Expand Up @@ -1124,6 +1124,7 @@ func GetKBFSPathInfo(standardPath string) (pathInfo keybase1.KBFSPathInfo, err e
}

func GetSafeFilename(filename string) (safeFilename string) {
filename = filepath.Base(filename)
if !utf8.ValidString(filename) {
return url.PathEscape(filename)
}
Expand Down

0 comments on commit 3592f81

Please sign in to comment.