Skip to content

Commit ffbcc34

Browse files
committed
Fixed bugs (mail attachments, unit-testing, etc.).
1 parent e5321b9 commit ffbcc34

5 files changed

Lines changed: 40 additions & 31 deletions

File tree

changes.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
======= 2.9.4 (HOTFIX)
2+
3+
- fixed: mail attachments
4+
- fixed: comparing `origin` header in WebSocket
5+
16
======= 2.9.3 (HOTFIX)
27

38
- added: `String.arg(obj)` for a simple templating `Hello {variable}!`

index.js

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
/**
2323
* @module Framework
24-
* @version 2.9.3
24+
* @version 2.9.4
2525
*/
2626

2727
'use strict';
@@ -526,8 +526,8 @@ var PERF = {};
526526
function Framework() {
527527

528528
this.$id = null; // F.id ==> property
529-
this.version = 2920;
530-
this.version_header = '2.9.2';
529+
this.version = 2940;
530+
this.version_header = '2.9.4';
531531
this.version_node = process.version.toString().replace('v', '').replace(/\./g, '').parseFloat();
532532

533533
this.config = {
@@ -13172,18 +13172,25 @@ WebSocketClient.prototype.prepare = function(flags, protocols, allow, length) {
1317213172
allow = allow || EMPTYARRAY;
1317313173

1317413174
var self = this;
13175+
13176+
if (SOCKET_ALLOW_VERSION.indexOf(U.parseInt(self.req.headers['sec-websocket-version'])) === -1)
13177+
return false;
13178+
1317513179
self.length = length;
1317613180

1317713181
var origin = self.req.headers['origin'] || '';
1317813182
var length = allow.length;
1317913183

13180-
if (length) {
13181-
if (allow.indexOf('*') === -1) {
13182-
for (var i = 0; i < length; i++) {
13183-
if (origin.indexOf(allow[i]) === -1)
13184-
return false;
13184+
if (length && allow.indexOf('*') === -1) {
13185+
var is = false;
13186+
for (var i = 0; i < length; i++) {
13187+
if (origin.indexOf(allow[i]) !== -1) {
13188+
is = true;
13189+
break;
1318513190
}
1318613191
}
13192+
if (!is)
13193+
return false;
1318713194
}
1318813195

1318913196
length = protocols.length;
@@ -13194,9 +13201,6 @@ WebSocketClient.prototype.prepare = function(flags, protocols, allow, length) {
1319413201
}
1319513202
}
1319613203

13197-
if (SOCKET_ALLOW_VERSION.indexOf(U.parseInt(self.req.headers['sec-websocket-version'])) === -1)
13198-
return false;
13199-
1320013204
var compress = (F.config['allow-websocket-compression'] && self.req.headers['sec-websocket-extensions'] || '').indexOf('permessage-deflate') !== -1;
1320113205
var header = protocols.length ? (compress ? SOCKET_RESPONSE_PROTOCOL_COMPRESS : SOCKET_RESPONSE_PROTOCOL).format(self.$websocket_key(self.req), protocols.join(', ')) : (compress ? SOCKET_RESPONSE_COMPRESS : SOCKET_RESPONSE).format(self.$websocket_key(self.req));
1320213206

mail.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
/**
2323
* @module FrameworkMail
24-
* @version 2.8.0
24+
* @version 2.9.4
2525
*/
2626

2727
'use strict';
@@ -248,7 +248,7 @@ Message.prototype.attachment = function(filename, name) {
248248
!name && (name = framework_utils.getName(filename));
249249
var extension = framework_utils.getExtension(name);
250250
!this.files && (this.files = []);
251-
this.files.push({ name: name, filename: filename, contentType: framework_utils.getContentType(extension), extension: extension });
251+
this.files.push({ name: name, filename: filename, type: framework_utils.getContentType(extension), extension: extension });
252252
return this;
253253
};
254254

@@ -257,7 +257,7 @@ Message.prototype.attachment = function(filename, name) {
257257
* @return {Message}
258258
*/
259259
Message.prototype.manually = function() {
260-
this.$sending && clearTimeout(this.$sending);
260+
this.$sending && clearImmediate(this.$sending);
261261
return this;
262262
};
263263

@@ -276,7 +276,7 @@ Message.prototype.attachmentInline = function(filename, name, contentId) {
276276
!name && (name = framework_utils.getName(filename));
277277
!this.files && (this.files = []);
278278
var extension = framework_utils.getExtension(name);
279-
this.files.push({ name: name, filename: filename, contentType: framework_utils.getContentType(extension), disposition: 'inline', contentId: contentId, extension: extension });
279+
this.files.push({ name: name, filename: filename, type: framework_utils.getContentType(extension), disposition: 'inline', contentId: contentId, extension: extension });
280280
return this;
281281
};
282282

@@ -353,6 +353,7 @@ Mailer.prototype.destroy = function(obj) {
353353
};
354354

355355
const ATTACHMENT_SO = { encoding: 'base64' };
356+
356357
Mailer.prototype.$writeattachment = function(obj) {
357358

358359
var attachment = obj.files ? obj.files.shift() : false;
@@ -379,7 +380,7 @@ Mailer.prototype.$writeattachment = function(obj) {
379380
message.push('Content-Disposition: attachment; filename="' + name + '"');
380381
}
381382

382-
message.push('Content-Type: ' + extension + ';' + (isCalendar ? ' charset="utf-8"; method=REQUEST' : ''));
383+
message.push('Content-Type: ' + attachment.type + ';' + (isCalendar ? ' charset="utf-8"; method=REQUEST' : ''));
383384
message.push('Content-Transfer-Encoding: base64');
384385
message.push(CRLF);
385386
mailer.$writeline(obj, message.join(CRLF));
@@ -647,7 +648,6 @@ Mailer.prototype.$send = function(obj, options, autosend) {
647648
var socket = obj.socket2 ? obj.socket2 : obj.socket;
648649
var host = obj.host;
649650
var line = null;
650-
651651
var isAttach = !options.tls || (obj.tls && options.tls);
652652

653653
isAttach && mailer.$events.send && mailer.emit('send', obj);
@@ -740,11 +740,11 @@ Mailer.prototype.$send = function(obj, options, autosend) {
740740
if (obj.messages.length) {
741741
mailer.$writemessage(obj, buffer);
742742
mailer.$writeline(obj, buffer.shift());
743-
return;
743+
} else {
744+
// end
745+
mailer.$writeline(obj, 'QUIT');
744746
}
745747

746-
// end
747-
mailer.$writeline(obj, 'QUIT');
748748
return;
749749

750750
case 221: // BYE
@@ -762,16 +762,16 @@ Mailer.prototype.$send = function(obj, options, autosend) {
762762
}
763763

764764
var value = auth.shift();
765-
if (!value) {
765+
if (value) {
766+
mailer.$writeline(obj, value);
767+
} else {
766768
var err = new Error('Forbidden.');
767769
mailer.destroy(obj);
768770
obj.callback && obj.callback(err);
769771
obj.callback = null;
770772
mailer.$events.error && !obj.try && mailer.emit('error', err, obj);
771-
return;
772773
}
773774

774-
mailer.$writeline(obj, value);
775775
return;
776776

777777
case 354:
@@ -796,12 +796,12 @@ Mailer.prototype.$send = function(obj, options, autosend) {
796796
buffer = [];
797797
obj.count--;
798798
socket.emit('line', '999 TRY NEXT MESSAGE');
799-
return;
799+
} else {
800+
mailer.destroy(obj);
801+
obj.callback && obj.callback(err);
802+
obj.callback = null;
800803
}
801804

802-
mailer.destroy(obj);
803-
obj.callback && obj.callback(err);
804-
obj.callback = null;
805805
return;
806806
}
807807
});

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@
9090
"name": "Tema Smirnov",
9191
"email": "github.tema@smirnov.one"
9292
}],
93-
"version": "2.9.30",
93+
"version": "2.9.4",
9494
"homepage": "http://www.totaljs.com",
9595
"bugs": {
9696
"url": "https://github.com/totaljs/framework/issues",

test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
/**
2323
* @module FrameworkTest
24-
* @version 2.9.0
24+
* @version 2.9.4
2525
*/
2626

2727
var T = F.tests = {};
@@ -73,7 +73,7 @@ function NEXT() {
7373
T.current = test;
7474
T.current.results = [];
7575

76-
console.log('[ TEST: ' + test.filename.substring(F.path.root('/tests/').length) + (T.current.priority ? ' ({0}) ]'.format(T.current.priority) : ' ]'));
76+
console.log('[ TEST: ' + test.filename.substring(F.path.tests().length) + (T.current.priority ? ' ({0}) ]'.format(T.current.priority) : ' ]'));
7777
console.log('');
7878

7979
NEXT();
@@ -130,7 +130,7 @@ global.OK = function(is, description) {
130130
};
131131

132132
exports.load = function() {
133-
U.ls(F.path.root('/tests/'), function(files) {
133+
U.ls(F.path.tests(), function(files) {
134134
files.waitFor(function(filename, next) {
135135
T.current = { filename: filename, items: [] };
136136
var m = require(filename);

0 commit comments

Comments
 (0)