|
@@ -1,6 +1,7 @@
|
|
|
module.exports = function(crowi) {
|
|
module.exports = function(crowi) {
|
|
|
var debug = require('debug')('crowi:models:revision')
|
|
var debug = require('debug')('crowi:models:revision')
|
|
|
, mongoose = require('mongoose')
|
|
, mongoose = require('mongoose')
|
|
|
|
|
+ , Xss = require('../util/xss')
|
|
|
, ObjectId = mongoose.Schema.Types.ObjectId
|
|
, ObjectId = mongoose.Schema.Types.ObjectId
|
|
|
, revisionSchema;
|
|
, revisionSchema;
|
|
|
|
|
|
|
@@ -12,6 +13,18 @@ module.exports = function(crowi) {
|
|
|
createdAt: { type: Date, default: Date.now }
|
|
createdAt: { type: Date, default: Date.now }
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|
|
+ /*
|
|
|
|
|
+ * preparation for https://github.com/weseek/crowi-plus/issues/216
|
|
|
|
|
+ */
|
|
|
|
|
+ // // create a XSS Filter instance
|
|
|
|
|
+ // // TODO read options
|
|
|
|
|
+ // this.xss = new Xss(true);
|
|
|
|
|
+ // // prevent XSS when pre save
|
|
|
|
|
+ // revisionSchema.pre('save', function(next) {
|
|
|
|
|
+ // this.body = xss.process(this.body);
|
|
|
|
|
+ // next();
|
|
|
|
|
+ // });
|
|
|
|
|
+
|
|
|
revisionSchema.statics.findLatestRevision = function(path, cb) {
|
|
revisionSchema.statics.findLatestRevision = function(path, cb) {
|
|
|
this.find({path: path})
|
|
this.find({path: path})
|
|
|
.sort({createdAt: -1})
|
|
.sort({createdAt: -1})
|