Skip to content

Commit cfdfafd

Browse files
authored
Merge pull request #856 from hackmdio/fix/lineEndings
Fix possible line-ending issues for init note
2 parents ec78c4f + b7b6218 commit cfdfafd

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

lib/response.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ function responseHackMD (res, note) {
145145

146146
function newNote (req, res, next) {
147147
var owner = null
148+
var body = req.body ? req.body : ''
149+
body = body.replace(/[\r]/g, '')
148150
if (req.isAuthenticated()) {
149151
owner = req.user.id
150152
} else if (!config.allowAnonymous) {
@@ -153,7 +155,7 @@ function newNote (req, res, next) {
153155
models.Note.create({
154156
ownerId: owner,
155157
alias: req.alias ? req.alias : null,
156-
content: req.body ? req.body : ''
158+
content: body
157159
}).then(function (note) {
158160
return res.redirect(config.serverURL + '/' + models.Note.encodeNoteId(note.id))
159161
}).catch(function (err) {

0 commit comments

Comments
 (0)