From 39c0ce66b925489a69fe6196b293d994e00f835a Mon Sep 17 00:00:00 2001 From: Rafael Kr Date: Tue, 1 Mar 2016 09:26:10 +0100 Subject: [PATCH 1/3] URL-decoded filename when sending file from stream This sends the file as "My File.ext" instead of "My%20File.ext". --- src/telegram.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/telegram.js b/src/telegram.js index 8f13bed..2f7f1b2 100644 --- a/src/telegram.js +++ b/src/telegram.js @@ -277,7 +277,7 @@ TelegramBot.prototype._formatSendData = function (type, data) { formData[type] = { value: data, options: { - filename: fileName, + filename: decodeURIComponent(fileName), contentType: mime.lookup(fileName) } }; From 54130e6df9ac945ca872fecdde3f0592072f6ecb Mon Sep 17 00:00:00 2001 From: Rafael Kr Date: Tue, 1 Mar 2016 10:47:09 +0100 Subject: [PATCH 2/3] Use of safer function qs.unescape I didn't know about that function, thank you. I've updated the code. --- src/telegram.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/telegram.js b/src/telegram.js index 2f7f1b2..47c06f7 100644 --- a/src/telegram.js +++ b/src/telegram.js @@ -277,7 +277,7 @@ TelegramBot.prototype._formatSendData = function (type, data) { formData[type] = { value: data, options: { - filename: decodeURIComponent(fileName), + filename: qs.unescape(fileName), contentType: mime.lookup(fileName) } }; From d1e4fd11ee6a298ebb3e74573a723f0294e5972e Mon Sep 17 00:00:00 2001 From: Rafael Kr Date: Tue, 1 Mar 2016 10:51:39 +0100 Subject: [PATCH 3/3] added module querystring Module querystring wasn't included before. --- src/telegram.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/telegram.js b/src/telegram.js index 47c06f7..27ca476 100644 --- a/src/telegram.js +++ b/src/telegram.js @@ -7,6 +7,7 @@ var EventEmitter = require('events').EventEmitter; var fileType = require('file-type'); var Promise = require('bluebird'); var request = require('request'); +var qs = require('querystring'); var stream = require('stream'); var util = require('util'); var mime = require('mime');