1
0
mirror of https://github.com/rclone/rclone.git synced 2025-01-24 12:56:36 +02:00

mega: fix key decoding - FIXME VENDOR PATCH DO NOT MERGE

See: https://forum.rclone.org/t/problem-to-login-with-mega/12276
This commit is contained in:
Nick Craig-Wood 2020-01-11 11:57:42 +00:00
parent ae340cf7d9
commit aefe18fc41

View File

@ -704,11 +704,20 @@ func (m *Mega) addFSNode(itm FSNode) (*Node, error) {
switch { switch {
case itm.T == FOLDER || itm.T == FILE: case itm.T == FOLDER || itm.T == FILE:
args := strings.Split(itm.Key, ":") args := strings.Split(itm.Key, ":")
if len(args) < 2 {
return nil, fmt.Errorf("not enough : in item.Key: %q", itm.Key)
}
itemUser, itemKey := args[0], args[1]
itemKeyParts := strings.Split(itemKey, "/")
if len(itemKeyParts) >= 2 {
itemKey = itemKeyParts[0]
// the other part is maybe a share key handle?
}
switch { switch {
// File or folder owned by current user // File or folder owned by current user
case args[0] == itm.User: case itemUser == itm.User:
buf, err := base64urldecode(args[1]) buf, err := base64urldecode(itemKey)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -736,7 +745,7 @@ func (m *Mega) addFSNode(itm FSNode) (*Node, error) {
} }
m.FS.skmap[itm.Hash] = itm.SKey m.FS.skmap[itm.Hash] = itm.SKey
buf, err := base64urldecode(args[1]) buf, err := base64urldecode(itemKey)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -750,7 +759,7 @@ func (m *Mega) addFSNode(itm FSNode) (*Node, error) {
} }
// Shared file // Shared file
default: default:
k := m.FS.skmap[args[0]] k := m.FS.skmap[itemUser]
b, err := base64urldecode(k) b, err := base64urldecode(k)
if err != nil { if err != nil {
return nil, err return nil, err
@ -763,7 +772,7 @@ func (m *Mega) addFSNode(itm FSNode) (*Node, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
buf, err := base64urldecode(args[1]) buf, err := base64urldecode(itemKey)
if err != nil { if err != nil {
return nil, err return nil, err
} }