Skip to content

Commit 429c92c

Browse files
committed
#3516 enforce line ending to be \n from web editor
1 parent 579e5e4 commit 429c92c

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

routers/repo/editor.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ func editFilePost(ctx *context.Context, form auth.EditRepoFileForm, isNewFile bo
263263
OldTreeName: oldTreePath,
264264
NewTreeName: form.TreePath,
265265
Message: message,
266-
Content: form.Content,
266+
Content: strings.Replace(form.Content, "\r", "", -1),
267267
IsNewFile: isNewFile,
268268
}); err != nil {
269269
ctx.Data["Err_TreePath"] = true
@@ -284,7 +284,6 @@ func NewFilePost(ctx *context.Context, form auth.EditRepoFileForm) {
284284

285285
func DiffPreviewPost(ctx *context.Context, form auth.EditPreviewDiffForm) {
286286
treePath := ctx.Repo.TreePath
287-
content := form.Content
288287

289288
entry, err := ctx.Repo.Commit.GetTreeEntryByPath(treePath)
290289
if err != nil {
@@ -295,7 +294,7 @@ func DiffPreviewPost(ctx *context.Context, form auth.EditPreviewDiffForm) {
295294
return
296295
}
297296

298-
diff, err := ctx.Repo.Repository.GetDiffPreview(ctx.Repo.BranchName, treePath, content)
297+
diff, err := ctx.Repo.Repository.GetDiffPreview(ctx.Repo.BranchName, treePath, form.Content)
299298
if err != nil {
300299
ctx.Error(500, "GetDiffPreview: "+err.Error())
301300
return

0 commit comments

Comments
 (0)