fix(SMB): use of @ and : chars in passwords (#8)

Fixes #4.
This commit is contained in:
Fabrice Marsaud 2016-06-06 12:11:29 +02:00 committed by Julien Fontanet
parent 808cc5d8d0
commit 220750f887
2 changed files with 32 additions and 4 deletions

View File

@ -18,8 +18,12 @@ export const parse = (remote) => {
remote.share = share
} else if (type === 'smb') {
remote.type = 'smb'
const [auth, smb] = rest.split('@')
const [username, password] = auth.split(':')
const lastArobas = rest.lastIndexOf('@')
const smb = rest.slice(lastArobas)
const auth = rest.slice(0, lastArobas)
const firstColon = auth.indexOf(':')
const username = auth.slice(0, firstColon)
const password = auth.slice(firstColon)
const [domain, sh] = smb.split('\\\\')
const [host, path] = sh.split('\0')
remote.host = host

View File

@ -24,6 +24,26 @@ const SMB = {
password: 'password'
}
const SMB_AROBAS = {
url: 'smb://Administrator:pass@word@toto\\\\192.168.100.225\\smb\0',
type: 'smb',
host: '192.168.100.225\\smb',
path: undefined,
domain: 'toto',
username: 'Administrator',
password: 'pass@word'
}
const SMB_COLON = {
url: 'smb://Administrator:pass:word@toto\\\\192.168.100.225\\smb\0',
type: 'smb',
host: '192.168.100.225\\smb',
path: undefined,
domain: 'toto',
username: 'Administrator',
password: 'pass:word'
}
const parseData = {
file: {
url: 'file://var/lib/xoa/backup', // Remotes formatted before fixing #7 will not break when reparses
@ -31,7 +51,9 @@ const parseData = {
path: '/var/lib/xoa/backup'
},
fileFixed: FILE_FIXED,
smb: SMB
smb: SMB,
'smb@inPassword': SMB_AROBAS,
'smb:inPassword': SMB_COLON
}
const formatData = {
@ -41,7 +63,9 @@ const formatData = {
path: '/var/lib/xoa/backup'
},
fileFixed: FILE_FIXED,
smb: SMB
smb: SMB,
'smb@inPassword': SMB_AROBAS,
'smb:inPassword': SMB_COLON
}
// -------------------------------------------------------------------