Skip to content
This repository has been archived by the owner on Apr 3, 2019. It is now read-only.

Fixes issue #2334 Pass an encoded hex email to DEL /emails #2336

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/db.js
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ module.exports = (

DB.prototype.setPrimaryEmail = function (uid, email) {
log.trace({op: 'DB.accountFromEmail', email: email})
return this.pool.post('/email/' + Buffer(email, 'utf8').toString('hex') + '/account/' + uid)
return this.pool.post('/email/' + hexEncode(email) + '/account/' + uid)
.then(
function (body) {
return body
Expand Down Expand Up @@ -1099,7 +1099,7 @@ module.exports = (
uid: uid
})

return this.pool.del('/account/' + uid + '/emails/' + email)
return this.pool.del('/account/' + uid + '/emails/' + hexEncode(email))
.catch(
function (err) {
if (isEmailDeletePrimaryError(err)) {
Expand Down Expand Up @@ -1209,7 +1209,7 @@ module.exports = (
}

function hexEncode(str) {
return Buffer(str, 'utf8').toString('hex')
return Buffer.from(str, 'utf8').toString('hex')
}

function safeRedisGet (key) {
Expand Down
Loading