summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2015-12-25 05:25:47 -0500
committerUnknwon <u@gogs.io>2015-12-25 05:25:47 -0500
commit85af36332b89a42152c7e2b76af5e2aeb048103a (patch)
treef1eabbd273416ecf34125183c1df994b2b0ca578
parent13fe73303726d74356a5d94bad7556802c2900a4 (diff)
downloadgitea-85af36332b89a42152c7e2b76af5e2aeb048103a.tar.gz
gitea-85af36332b89a42152c7e2b76af5e2aeb048103a.zip
#2282 fix utf-8 recognized as windows-1252
-rw-r--r--cmd/serve.go2
-rw-r--r--gogs.go2
-rw-r--r--modules/base/tool.go4
-rw-r--r--modules/template/template.go10
-rw-r--r--routers/user/profile.go3
-rw-r--r--templates/.VERSION2
6 files changed, 13 insertions, 10 deletions
diff --git a/cmd/serve.go b/cmd/serve.go
index 69ee9b7b1d..7a24fc2597 100644
--- a/cmd/serve.go
+++ b/cmd/serve.go
@@ -209,7 +209,7 @@ func runServ(c *cli.Context) {
}
// Check if this deploy key belongs to current repository.
if !models.HasDeployKey(key.ID, repo.ID) {
- fail("Key access denied", "Key access denied: %d-%d", key.ID, repo.ID)
+ fail("Key access denied", "Key access denied: [key_id: %d, repo_id: %d]", key.ID, repo.ID)
}
// Update deploy key activity.
diff --git a/gogs.go b/gogs.go
index 97edd504d0..46d7e3386c 100644
--- a/gogs.go
+++ b/gogs.go
@@ -17,7 +17,7 @@ import (
"github.com/gogits/gogs/modules/setting"
)
-const APP_VER = "0.8.13.1224"
+const APP_VER = "0.8.13.1225"
func init() {
runtime.GOMAXPROCS(runtime.NumCPU())
diff --git a/modules/base/tool.go b/modules/base/tool.go
index 46eeca9b2b..9dcbb881d5 100644
--- a/modules/base/tool.go
+++ b/modules/base/tool.go
@@ -25,6 +25,7 @@ import (
"golang.org/x/net/html/charset"
"github.com/gogits/gogs/modules/avatar"
+ "github.com/gogits/gogs/modules/log"
"github.com/gogits/gogs/modules/setting"
)
@@ -52,7 +53,8 @@ func ShortSha(sha1 string) string {
}
func DetectEncoding(content []byte) string {
- _, name, _ := charset.DetermineEncoding(content, setting.Repository.AnsiCharset)
+ _, name, certain := charset.DetermineEncoding(content, setting.Repository.AnsiCharset)
+ log.Debug("Detected encoding: %s (%v)", name, certain)
return name
}
diff --git a/modules/template/template.go b/modules/template/template.go
index 638febe89d..4149de451a 100644
--- a/modules/template/template.go
+++ b/modules/template/template.go
@@ -12,6 +12,7 @@ import (
"runtime"
"strings"
"time"
+ "unicode/utf8"
"golang.org/x/net/html/charset"
"golang.org/x/text/transform"
@@ -130,20 +131,19 @@ func Sha1(str string) string {
}
func ToUtf8WithErr(content []byte) (error, string) {
- charsetLabel := base.DetectEncoding(content)
- if charsetLabel == "UTF-8" {
+ if utf8.Valid(content[:1024]) {
return nil, string(content)
}
+ charsetLabel := base.DetectEncoding(content)
encoding, _ := charset.Lookup(charsetLabel)
if encoding == nil {
- return fmt.Errorf("unknown char decoder %s", charsetLabel), string(content)
+ return fmt.Errorf("Unknown encoding: %s", charsetLabel), string(content)
}
- result, n, err := transform.String(encoding.NewDecoder(), string(content))
-
// If there is an error, we concatenate the nicely decoded part and the
// original left over. This way we won't loose data.
+ result, n, err := transform.String(encoding.NewDecoder(), string(content))
if err != nil {
result = result + string(content[n:])
}
diff --git a/routers/user/profile.go b/routers/user/profile.go
index b531523e65..9007ab326f 100644
--- a/routers/user/profile.go
+++ b/routers/user/profile.go
@@ -6,6 +6,7 @@ package user
import (
"fmt"
+ "path"
"strings"
"github.com/gogits/gogs/models"
@@ -38,7 +39,7 @@ func Profile(ctx *middleware.Context) {
uname := ctx.Params(":username")
// Special handle for FireFox requests favicon.ico.
if uname == "favicon.ico" {
- ctx.Redirect(setting.AppSubUrl + "/img/favicon.png")
+ ctx.ServeFile(path.Join(setting.StaticRootPath, "public/img/favicon.png"))
return
} else if strings.HasSuffix(uname, ".png") {
ctx.Error(404)
diff --git a/templates/.VERSION b/templates/.VERSION
index 0aae64d7b0..e0c3ee2f26 100644
--- a/templates/.VERSION
+++ b/templates/.VERSION
@@ -1 +1 @@
-0.8.13.1224 \ No newline at end of file
+0.8.13.1225 \ No newline at end of file