1
0
mirror of https://github.com/dutchcoders/transfer.sh.git synced 2020-11-18 19:53:40 -08:00

Merge pull request #143 from dutchcoders/FIX-GDRIVE-FILENAME-ESCAPING

Escape quoting chars in filename for gdrive
This commit is contained in:
Andrea Spacca 2018-07-13 06:45:39 +02:00 committed by GitHub
commit a640bcf707
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -21,6 +21,7 @@ import (
"google.golang.org/api/googleapi" "google.golang.org/api/googleapi"
"io/ioutil" "io/ioutil"
"net/http" "net/http"
"strings"
) )
type Storage interface { type Storage interface {
@ -391,6 +392,9 @@ func (s *GDrive) list(nextPageToken string, q string) (*drive.FileList, error) {
} }
func (s *GDrive) findId(filename string, token string) (string, error) { func (s *GDrive) findId(filename string, token string) (string, error) {
filename = strings.Replace(filename, `'`, `\'`, -1)
filename = strings.Replace(filename, `"`, `\"`, -1)
fileId, tokenId, nextPageToken := "", "", "" fileId, tokenId, nextPageToken := "", "", ""
q := fmt.Sprintf("'%s' in parents and name='%s' and mimeType='%s' and trashed=false", s.rootId, token, GDriveDirectoryMimeType) q := fmt.Sprintf("'%s' in parents and name='%s' and mimeType='%s' and trashed=false", s.rootId, token, GDriveDirectoryMimeType)