Merge pull request #856 from hackmdio/fix/lineEndings

Fix possible line-ending issues for init note
This commit is contained in:
Christoph (Sheogorath) Kern 2018-06-24 01:57:47 +02:00 committed by GitHub
commit cfdfafdb79
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -145,6 +145,8 @@ function responseHackMD (res, note) {
function newNote (req, res, next) { function newNote (req, res, next) {
var owner = null var owner = null
var body = req.body ? req.body : ''
body = body.replace(/[\r]/g, '')
if (req.isAuthenticated()) { if (req.isAuthenticated()) {
owner = req.user.id owner = req.user.id
} else if (!config.allowAnonymous) { } else if (!config.allowAnonymous) {
@ -153,7 +155,7 @@ function newNote (req, res, next) {
models.Note.create({ models.Note.create({
ownerId: owner, ownerId: owner,
alias: req.alias ? req.alias : null, alias: req.alias ? req.alias : null,
content: req.body ? req.body : '' content: body
}).then(function (note) { }).then(function (note) {
return res.redirect(config.serverURL + '/' + models.Note.encodeNoteId(note.id)) return res.redirect(config.serverURL + '/' + models.Note.encodeNoteId(note.id))
}).catch(function (err) { }).catch(function (err) {