not using Posts.parsePost for diffs parsing

v1.18.x
Julian Lam 7 years ago
parent 5069892b97
commit c938711f9c

@ -2,9 +2,11 @@
var async = require('async'); var async = require('async');
var validator = require('validator'); var validator = require('validator');
var diff = require('diff');
var db = require('../database'); var db = require('../database');
var diff = require('diff'); var plugins = require('../plugins');
var translator = require('../translator');
module.exports = function (Posts) { module.exports = function (Posts) {
Posts.diffs = {}; Posts.diffs = {};
@ -50,16 +52,26 @@ module.exports = function (Posts) {
// Replace content with re-constructed content from that point in time // Replace content with re-constructed content from that point in time
data.post.content = data.diffs.reverse().reduce(function (content, diffString) { data.post.content = data.diffs.reverse().reduce(function (content, diffString) {
return diff.applyPatch(content, diffString); return diff.applyPatch(content, diffString, {
fuzzFactor: 1,
});
}, data.post.content); }, data.post.content);
// Clear editor data (as it is outdated for this content) // Clear editor data (as it is outdated for this content)
delete data.post.edited; delete data.post.edited;
data.post.editor = null; data.post.editor = null;
Posts.parsePost(data.post, function (err, post) { data.post.content = String(data.post.content || '');
callback(err, post);
}); async.waterfall([
function (next) {
plugins.fireHook('filter:parse.post', { postData: data.post }, next);
},
function (data, next) {
data.postData.content = translator.escape(data.postData.content);
next(null, data.postData);
},
], callback);
}); });
}; };
}; };

Loading…
Cancel
Save