diff --git a/app/assets/server/assets.js b/app/assets/server/assets.js index 8864c8e372fa3..cd9c0f0bc6b63 100644 --- a/app/assets/server/assets.js +++ b/app/assets/server/assets.js @@ -209,7 +209,7 @@ export const RocketChatAssets = new class { }); } - const file = new Buffer(binaryContent, 'binary'); + const file = Buffer.from(binaryContent, 'binary'); if (assets[asset].constraints.width || assets[asset].constraints.height) { const dimensions = sizeOf(file); if (assets[asset].constraints.width && assets[asset].constraints.width !== dimensions.width) { diff --git a/app/custom-sounds/server/methods/uploadCustomSound.js b/app/custom-sounds/server/methods/uploadCustomSound.js index ebeecefb1e229..3366bdf636a65 100644 --- a/app/custom-sounds/server/methods/uploadCustomSound.js +++ b/app/custom-sounds/server/methods/uploadCustomSound.js @@ -11,7 +11,7 @@ Meteor.methods({ throw new Meteor.Error('not_authorized'); } - const file = new Buffer(binaryContent, 'binary'); + const file = Buffer.from(binaryContent, 'binary'); const rs = RocketChatFile.bufferToStream(file); RocketChatFileCustomSoundsInstance.deleteFile(`${ soundData._id }.${ soundData.extension }`); diff --git a/app/emoji-custom/server/methods/uploadEmojiCustom.js b/app/emoji-custom/server/methods/uploadEmojiCustom.js index 1f3d4cf4d1c43..0302aa8caa4ae 100644 --- a/app/emoji-custom/server/methods/uploadEmojiCustom.js +++ b/app/emoji-custom/server/methods/uploadEmojiCustom.js @@ -15,7 +15,7 @@ Meteor.methods({ emojiData.name = limax(emojiData.name, { replacement: '_' }); // delete aliases for notification purposes. here, it is a string rather than an array delete emojiData.aliases; - const file = new Buffer(binaryContent, 'binary'); + const file = Buffer.from(binaryContent, 'binary'); const rs = RocketChatFile.bufferToStream(file); RocketChatFileEmojiCustomInstance.deleteFile(encodeURIComponent(`${ emojiData.name }.${ emojiData.extension }`)); diff --git a/app/importer-hipchat/server/importer.js b/app/importer-hipchat/server/importer.js index 49f6b8e2e4d0c..acf521f2305d4 100644 --- a/app/importer-hipchat/server/importer.js +++ b/app/importer-hipchat/server/importer.js @@ -31,7 +31,7 @@ export class HipChatImporter extends Base { super.prepare(dataURI, sentContentType, fileName, skipTypeCheck); const { image } = RocketChatFile.dataURIParse(dataURI); // const contentType = ref.contentType; - const zip = new this.AdmZip(new Buffer(image, 'base64')); + const zip = new this.AdmZip(Buffer.from(image, 'base64')); const zipEntries = zip.getEntries(); let tempRooms = []; let tempUsers = []; diff --git a/app/importer-slack-users/server/importer.js b/app/importer-slack-users/server/importer.js index 0024842e43612..8f7068caf65cc 100644 --- a/app/importer-slack-users/server/importer.js +++ b/app/importer-slack-users/server/importer.js @@ -26,7 +26,7 @@ export class SlackUsersImporter extends Base { super.updateProgress(ProgressStep.PREPARING_USERS); const uriResult = RocketChatFile.dataURIParse(dataURI); - const buf = new Buffer(uriResult.image, 'base64'); + const buf = Buffer.from(uriResult.image, 'base64'); const parsed = this.csvParser(buf.toString()); parsed.forEach((user, index) => { diff --git a/app/importer/server/classes/ImporterBase.js b/app/importer/server/classes/ImporterBase.js index a8c5c3cea55d1..df2052eb8d6d3 100644 --- a/app/importer/server/classes/ImporterBase.js +++ b/app/importer/server/classes/ImporterBase.js @@ -140,7 +140,7 @@ export class Base { */ prepareUsingLocalFile(fullFilePath) { const file = fs.readFileSync(fullFilePath); - const buffer = Buffer.isBuffer(file) ? file : new Buffer(file); + const buffer = Buffer.isBuffer(file) ? file : Buffer.from(file); const { contentType } = this.importRecord; const fileName = this.importRecord.file; @@ -163,7 +163,7 @@ export class Base { prepare(dataURI, sentContentType, fileName, skipTypeCheck) { this.collection.remove({}); if (!skipTypeCheck) { - const fileType = this.getFileType(new Buffer(dataURI.split(',')[1], 'base64')); + const fileType = this.getFileType(Buffer.from(dataURI.split(',')[1], 'base64')); this.logger.debug('Uploaded file information is:', fileType); this.logger.debug('Expected file type is:', this.info.mimeType); diff --git a/app/importer/server/methods/uploadImportFile.js b/app/importer/server/methods/uploadImportFile.js index 0db5bba69bf2c..bdd9aefb178c1 100644 --- a/app/importer/server/methods/uploadImportFile.js +++ b/app/importer/server/methods/uploadImportFile.js @@ -34,7 +34,7 @@ Meteor.methods({ importer.instance.startFileUpload(newFileName, contentType); // Save the file on the File Store - const file = new Buffer(binaryContent, 'base64'); + const file = Buffer.from(binaryContent, 'base64'); const readStream = RocketChatFile.bufferToStream(file); const writeStream = RocketChatImportFileInstance.createWriteStream(newFileName, contentType); diff --git a/app/irc/server/servers/RFC2813/index.js b/app/irc/server/servers/RFC2813/index.js index 1325da3851f23..6d6335c4017ba 100644 --- a/app/irc/server/servers/RFC2813/index.js +++ b/app/irc/server/servers/RFC2813/index.js @@ -18,7 +18,7 @@ class RFC2813 { this.serverPrefix = null; // Hold the buffer while receiving - this.receiveBuffer = new Buffer(''); + this.receiveBuffer = Buffer.from(''); } /** @@ -136,7 +136,7 @@ class RFC2813 { } // Reset the buffer - this.receiveBuffer = new Buffer(''); + this.receiveBuffer = Buffer.from(''); lines.forEach((line) => { if (line.length && !line.startsWith('\a')) { diff --git a/app/ldap/server/ldap.js b/app/ldap/server/ldap.js index 63c5951b43d24..0dceec62d8868 100644 --- a/app/ldap/server/ldap.js +++ b/app/ldap/server/ldap.js @@ -258,14 +258,14 @@ export default class LDAP { if (attribute) { filter = new this.ldapjs.filters.EqualityFilter({ attribute, - value: new Buffer(id, 'hex'), + value: Buffer.from(id, 'hex'), }); } else { const filters = []; Unique_Identifier_Field.forEach((item) => { filters.push(new this.ldapjs.filters.EqualityFilter({ attribute: item, - value: new Buffer(id, 'hex'), + value: Buffer.from(id, 'hex'), })); }); diff --git a/app/lib/server/functions/setUserAvatar.js b/app/lib/server/functions/setUserAvatar.js index 7229d5a294e4e..de759c7831315 100644 --- a/app/lib/server/functions/setUserAvatar.js +++ b/app/lib/server/functions/setUserAvatar.js @@ -51,7 +51,7 @@ export const setUserAvatar = function(user, dataURI, contentType, service) { contentType = fileData.contentType; } - const buffer = new Buffer(image, encoding); + const buffer = Buffer.from(image, encoding); const fileStore = FileUpload.getStore('Avatars'); fileStore.deleteByName(user.username); diff --git a/app/meteor-accounts-saml/server/lib/ServiceProvider.ts b/app/meteor-accounts-saml/server/lib/ServiceProvider.ts index 3733821bcd552..5ab421c7903dd 100644 --- a/app/meteor-accounts-saml/server/lib/ServiceProvider.ts +++ b/app/meteor-accounts-saml/server/lib/ServiceProvider.ts @@ -182,7 +182,7 @@ export class SAMLServiceProvider { } public validateResponse(samlResponse: string, callback: IResponseValidateCallback): void { - const xml = new Buffer(samlResponse, 'base64').toString('utf8'); + const xml = Buffer.from(samlResponse, 'base64').toString('utf8'); const parser = new ResponseParser(this.serviceProviderOptions); return parser.validate(xml, callback); diff --git a/app/meteor-accounts-saml/server/lib/Utils.ts b/app/meteor-accounts-saml/server/lib/Utils.ts index 86aa5c7cf3108..9acd3331a4b32 100644 --- a/app/meteor-accounts-saml/server/lib/Utils.ts +++ b/app/meteor-accounts-saml/server/lib/Utils.ts @@ -152,7 +152,7 @@ export class SAMLUtils { } public static inflateXml(base64Data: string, successCallback: (xml: string) => void, errorCallback: (err: string | object | null) => void): void { - const buffer = new Buffer(base64Data, 'base64'); + const buffer = Buffer.from(base64Data, 'base64'); zlib.inflateRaw(buffer, (err, decoded) => { if (err) { this.log(`Error while inflating. ${ err }`); diff --git a/app/webdav/server/methods/uploadFileToWebdav.ts b/app/webdav/server/methods/uploadFileToWebdav.ts index a7f295205e5ff..b818579dcf1d2 100644 --- a/app/webdav/server/methods/uploadFileToWebdav.ts +++ b/app/webdav/server/methods/uploadFileToWebdav.ts @@ -24,7 +24,7 @@ Meteor.methods({ } const uploadFolder = 'Rocket.Chat Uploads/'; - const buffer = new Buffer(fileData); + const buffer = Buffer.from(fileData); try { const cred = getWebdavCredentials(account); diff --git a/server/routes/avatar/utils.js b/server/routes/avatar/utils.js index 0e75fc52f530a..21d1a742f25ca 100644 --- a/server/routes/avatar/utils.js +++ b/server/routes/avatar/utils.js @@ -15,7 +15,7 @@ export const serveAvatar = (avatar, format, res) => { if (['png', 'jpg', 'jpeg'].includes(format)) { res.setHeader('Content-Type', `image/${ format }`); - sharp(new Buffer(avatar)) + sharp(Buffer.from(avatar)) .toFormat(format) .pipe(res); return; diff --git a/server/startup/migrations/v002.js b/server/startup/migrations/v002.js index cf80409dd16c6..005fb77f23d8d 100644 --- a/server/startup/migrations/v002.js +++ b/server/startup/migrations/v002.js @@ -29,7 +29,7 @@ Migrations.add({ const dataURI = avatars[service].blob; const { image, contentType } = RocketChatFile.dataURIParse(dataURI); - const rs = RocketChatFile.bufferToStream(new Buffer(image, 'base64')); + const rs = RocketChatFile.bufferToStream(Buffer.from(image, 'base64')); const fileStore = FileUpload.getStore('Avatars'); fileStore.deleteByName(user.username);