Merge branch 'master' of ssh://numinibsd/git/base/enigma-bbs
This commit is contained in:
commit
175ad970bf
|
@ -1,19 +1,20 @@
|
||||||
/* jslint node: true */
|
/* jslint node: true */
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
let ftn = require('./ftn_util.js');
|
const ftn = require('./ftn_util.js');
|
||||||
let Message = require('./message.js');
|
const Message = require('./message.js');
|
||||||
let sauce = require('./sauce.js');
|
const sauce = require('./sauce.js');
|
||||||
let Address = require('./ftn_address.js');
|
const Address = require('./ftn_address.js');
|
||||||
let strUtil = require('./string_util.js');
|
const strUtil = require('./string_util.js');
|
||||||
|
const Log = require('./logger.js').log;
|
||||||
|
|
||||||
let _ = require('lodash');
|
const _ = require('lodash');
|
||||||
let assert = require('assert');
|
const assert = require('assert');
|
||||||
let binary = require('binary');
|
const binary = require('binary');
|
||||||
let fs = require('fs');
|
const fs = require('fs');
|
||||||
let async = require('async');
|
const async = require('async');
|
||||||
let iconv = require('iconv-lite');
|
const iconv = require('iconv-lite');
|
||||||
let moment = require('moment');
|
const moment = require('moment');
|
||||||
|
|
||||||
exports.Packet = Packet;
|
exports.Packet = Packet;
|
||||||
|
|
||||||
|
@ -473,7 +474,7 @@ function Packet(options) {
|
||||||
try {
|
try {
|
||||||
decoded = iconv.decode(messageBodyBuffer, encoding);
|
decoded = iconv.decode(messageBodyBuffer, encoding);
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
// :TODO: add log warning here including failure reason
|
Log.debug( { encoding : encoding, error : e.toString() }, 'Error decoding. Falling back to ASCII');
|
||||||
decoded = iconv.decode(messageBodyBuffer, 'ascii');
|
decoded = iconv.decode(messageBodyBuffer, 'ascii');
|
||||||
}
|
}
|
||||||
//const messageLines = iconv.decode(messageBodyBuffer, encoding).replace(/\xec/g, '').split(/\r\n|[\n\v\f\r\x85\u2028\u2029]/g);
|
//const messageLines = iconv.decode(messageBodyBuffer, encoding).replace(/\xec/g, '').split(/\r\n|[\n\v\f\r\x85\u2028\u2029]/g);
|
||||||
|
@ -720,12 +721,19 @@ function Packet(options) {
|
||||||
|
|
||||||
appendMeta('\x01PATH', message.meta.FtnKludge['PATH']);
|
appendMeta('\x01PATH', message.meta.FtnKludge['PATH']);
|
||||||
|
|
||||||
|
let msgBodyEncoded;
|
||||||
|
try {
|
||||||
|
msgBodyEncoded = iconv.encode(msgBody + '\0', options.encoding);
|
||||||
|
} catch(e) {
|
||||||
|
msgBodyEncoded = iconv.encode(msgBody + '\0', 'ascii');
|
||||||
|
}
|
||||||
|
|
||||||
return Buffer.concat( [
|
return Buffer.concat( [
|
||||||
basicHeader,
|
basicHeader,
|
||||||
toUserNameBuf,
|
toUserNameBuf,
|
||||||
fromUserNameBuf,
|
fromUserNameBuf,
|
||||||
subjectBuf,
|
subjectBuf,
|
||||||
iconv.encode(msgBody + '\0', options.encoding)
|
msgBodyEncoded
|
||||||
]);
|
]);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -331,7 +331,7 @@ function getNewMessagesInAreaForUser(userId, areaTag, cb) {
|
||||||
sql +=
|
sql +=
|
||||||
` AND message_id in (
|
` AND message_id in (
|
||||||
SELECT message_id from message_meta where meta_category ="System"
|
SELECT message_id from message_meta where meta_category ="System"
|
||||||
AND meta_name ="${Message.SystemMetaNames.LocalToUserID}" AND meta_value =${userId})`;
|
AND meta_name = "${Message.SystemMetaNames.LocalToUserID}" AND meta_value = ${userId})`;
|
||||||
}
|
}
|
||||||
|
|
||||||
sql += ' ORDER BY message_id;';
|
sql += ' ORDER BY message_id;';
|
||||||
|
|
|
@ -22,6 +22,7 @@ const temp = require('temp').track(); // track() cleans up temp dir/files fo
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const gaze = require('gaze');
|
const gaze = require('gaze');
|
||||||
const fse = require('fs-extra');
|
const fse = require('fs-extra');
|
||||||
|
const iconv = require('iconv-lite');
|
||||||
|
|
||||||
exports.moduleInfo = {
|
exports.moduleInfo = {
|
||||||
name : 'FTN BSO',
|
name : 'FTN BSO',
|
||||||
|
@ -359,6 +360,7 @@ function FTNMessageScanTossModule() {
|
||||||
//
|
//
|
||||||
// Determine CHRS and actual internal encoding name
|
// Determine CHRS and actual internal encoding name
|
||||||
// Try to preserve anything already here
|
// Try to preserve anything already here
|
||||||
|
//
|
||||||
let encoding = options.nodeConfig.encoding || 'utf8';
|
let encoding = options.nodeConfig.encoding || 'utf8';
|
||||||
if(message.meta.FtnKludge.CHRS) {
|
if(message.meta.FtnKludge.CHRS) {
|
||||||
const encFromChars = ftnUtil.getEncodingFromCharacterSetIdentifier(message.meta.FtnKludge.CHRS);
|
const encFromChars = ftnUtil.getEncodingFromCharacterSetIdentifier(message.meta.FtnKludge.CHRS);
|
||||||
|
@ -367,6 +369,14 @@ function FTNMessageScanTossModule() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Ensure we ended up with something useable. If not, back to utf8!
|
||||||
|
//
|
||||||
|
if(!iconv.encodingExists(encoding)) {
|
||||||
|
Log.debug( { encoding : encoding }, 'Unknown encoding. Falling back to utf8');
|
||||||
|
encoding = 'utf8';
|
||||||
|
}
|
||||||
|
|
||||||
options.encoding = encoding; // save for later
|
options.encoding = encoding; // save for later
|
||||||
message.meta.FtnKludge.CHRS = ftnUtil.getCharacterSetIdentifierByEncoding(encoding);
|
message.meta.FtnKludge.CHRS = ftnUtil.getCharacterSetIdentifierByEncoding(encoding);
|
||||||
// :TODO: FLAGS kludge?
|
// :TODO: FLAGS kludge?
|
||||||
|
@ -987,7 +997,7 @@ function FTNMessageScanTossModule() {
|
||||||
//nextFile();
|
//nextFile();
|
||||||
} else {
|
} else {
|
||||||
self.archivePacketFile('import', fullPath, 'imported', () => {
|
self.archivePacketFile('import', fullPath, 'imported', () => {
|
||||||
fs.unlink(fullPath, err => {
|
fs.unlink(fullPath, () => {
|
||||||
nextFile();
|
nextFile();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue