From 9e6bd31d76aa6d6495a2144466af78773f34d07c Mon Sep 17 00:00:00 2001 From: Don Bowman Date: Wed, 12 Aug 2015 21:07:44 +0000 Subject: [PATCH 1/4] fixes for binary --- modules/base/markdown.go | 1 - routers/repo/download.go | 1 - 2 files changed, 2 deletions(-) diff --git a/modules/base/markdown.go b/modules/base/markdown.go index d06e1338e..03f1287c1 100644 --- a/modules/base/markdown.go +++ b/modules/base/markdown.go @@ -198,7 +198,6 @@ func RenderRawMarkdown(body []byte, urlPrefix string) []byte { extensions |= blackfriday.EXTENSION_FENCED_CODE extensions |= blackfriday.EXTENSION_AUTOLINK extensions |= blackfriday.EXTENSION_STRIKETHROUGH - extensions |= blackfriday.EXTENSION_HARD_LINE_BREAK extensions |= blackfriday.EXTENSION_SPACE_HEADERS extensions |= blackfriday.EXTENSION_NO_EMPTY_LINE_BEFORE_BLOCK diff --git a/routers/repo/download.go b/routers/repo/download.go index c5e18e005..b1c5fbc84 100644 --- a/routers/repo/download.go +++ b/routers/repo/download.go @@ -27,7 +27,6 @@ func ServeBlob(ctx *middleware.Context, blob *git.Blob) error { _, isTextFile := base.IsTextFile(buf) _, isImageFile := base.IsImageFile(buf) - ctx.Resp.Header().Set("Content-Type", "text/plain") if !isTextFile && !isImageFile { ctx.Resp.Header().Set("Content-Disposition", "attachment; filename="+path.Base(ctx.Repo.TreeName)) ctx.Resp.Header().Set("Content-Transfer-Encoding", "binary") From ab0247b4dc0b968a68bbb75c97d5fe022cca427a Mon Sep 17 00:00:00 2001 From: Don Bowman Date: Wed, 12 Aug 2015 22:00:43 +0000 Subject: [PATCH 2/4] race condition on keydelete --- models/publickey.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/models/publickey.go b/models/publickey.go index 70da8057c..3ef84b9c7 100644 --- a/models/publickey.go +++ b/models/publickey.go @@ -386,8 +386,6 @@ func ListPublicKeys(uid int64) ([]*PublicKey, error) { // rewriteAuthorizedKeys finds and deletes corresponding line in authorized_keys file. func rewriteAuthorizedKeys(key *PublicKey, p, tmpP string) error { - sshOpLocker.Lock() - defer sshOpLocker.Unlock() fr, err := os.Open(p) if err != nil { @@ -444,6 +442,9 @@ func UpdatePublicKey(key *PublicKey) error { } func deletePublicKey(e *xorm.Session, key *PublicKey) error { + sshOpLocker.Lock() + defer sshOpLocker.Unlock() + has, err := e.Get(key) if err != nil { return err From 599e9040205ee14e60e811e5b6ac6ebbd1601477 Mon Sep 17 00:00:00 2001 From: Don Bowman Date: Thu, 13 Aug 2015 23:15:55 +0000 Subject: [PATCH 3/4] 43bfee0d4872932c1da185e8367e21795bc4ceb5 reverted my change 423b1c69be7828c331a47467b66217d190e916b9, which in turn causes all content to be served as text/plain. Let go decide what the mime type is (e.g. text/html instead of text/plain). --- routers/repo/download.go | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/routers/repo/download.go b/routers/repo/download.go index c71f8d293..a73ecb37e 100644 --- a/routers/repo/download.go +++ b/routers/repo/download.go @@ -26,12 +26,7 @@ func ServeBlob(ctx *middleware.Context, blob *git.Blob) error { } _, isTextFile := base.IsTextFile(buf) - if isTextFile { - charset, _ := base.DetectEncoding(buf) - if charset != "UTF-8" { - ctx.Resp.Header().Set("Content-Type", "text/plain; charset="+charset) - } - } else { + if ! isTextFile { _, isImageFile := base.IsImageFile(buf) if !isImageFile { ctx.Resp.Header().Set("Content-Disposition", "attachment; filename="+path.Base(ctx.Repo.TreeName)) From 1d52793faf91b93e52b27c56e7be3fd9ca373d54 Mon Sep 17 00:00:00 2001 From: Don Bowman Date: Sat, 15 Aug 2015 09:21:34 +0000 Subject: [PATCH 4/4] remove empty line as per https://github.com/gogits/gogs/pull/1475 --- models/publickey.go | 1 - 1 file changed, 1 deletion(-) diff --git a/models/publickey.go b/models/publickey.go index 3ef84b9c7..400486eba 100644 --- a/models/publickey.go +++ b/models/publickey.go @@ -386,7 +386,6 @@ func ListPublicKeys(uid int64) ([]*PublicKey, error) { // rewriteAuthorizedKeys finds and deletes corresponding line in authorized_keys file. func rewriteAuthorizedKeys(key *PublicKey, p, tmpP string) error { - fr, err := os.Open(p) if err != nil { return err