Browse Source

modules/base: add RenderCommitMessage with XSS-safe and special links

- update russian locale
for-closed-social
Unknwon 9 years ago
parent
commit
37fcc8daf2
12 changed files with 27 additions and 21 deletions
  1. +1
    -1
      README.md
  2. +1
    -1
      README_ZH.md
  3. +9
    -9
      conf/locale/locale_ru-RU.ini
  4. +1
    -1
      gogs.go
  5. +1
    -1
      modules/base/markdown.go
  6. +6
    -0
      modules/base/template.go
  7. +2
    -2
      routers/repo/commit.go
  8. +2
    -2
      routers/repo/view.go
  9. +1
    -1
      templates/.VERSION
  10. +1
    -1
      templates/repo/commits_table.tmpl
  11. +1
    -1
      templates/repo/diff.tmpl
  12. +1
    -1
      templates/repo/view_list.tmpl

+ 1
- 1
README.md View File

@ -7,7 +7,7 @@ Gogs(Go Git Service) is a painless self-hosted Git Service written in Go.
![Demo](http://gogs.qiniudn.com/gogs_demo.gif)
##### Current version: 0.5.11 Beta
##### Current version: 0.5.12 Beta
### NOTICES

+ 1
- 1
README_ZH.md View File

@ -5,7 +5,7 @@ Gogs(Go Git Service) 是一个基于 Go 语言的自助 Git 服务。
![Demo](http://gogs.qiniudn.com/gogs_demo.gif)
##### 当前版本:0.5.11 Beta
##### 当前版本:0.5.12 Beta
## 开发目的

+ 9
- 9
conf/locale/locale_ru-RU.ini View File

@ -164,7 +164,7 @@ unable_verify_ssh_key=Gogs не может проверить ваш SSH-клю
auth_failed=Ошибка аутентификации: %v
still_own_repo=На вашем аккаунте все еще остается как минимум один репозиторий, сначала вам нужно удалить или передать его.
still_has_org=Your account still have membership of organization, you have to left or delete them first.
still_has_org=Вы находитесь в организации, сперва Вам необходимо покинуть ее или удалить.
org_still_own_repo=Данная организация все еще является владельцем репозиториев, необходимо удалить или переместить их в начале.
still_own_user=Эта проверка подлинности по-прежнему используется некоторыми пользователями, вы должны переместить их и затем снова удалить.
@ -631,22 +631,22 @@ config.db_path_helper=(for "sqlite3" only)
config.service_config=Service Configuration
config.register_email_confirm=Require E-mail Confirmation
config.disable_register=Отключить регистрацию
config.require_sign_in_view=Require Sign In View
config.mail_notify=Mail Notification
config.enable_cache_avatar=Enable Cache Avatar
config.require_sign_in_view=Для просмотра необходима авторизация
config.mail_notify=Почтовые уведомления
config.enable_cache_avatar=Кешировать аватар
config.active_code_lives=Active Code Lives
config.reset_password_code_lives=Reset Password Code Lives
config.webhook_config=Настройка автоматического обновления репозиции
config.task_interval=Task Interval
config.deliver_timeout=Deliver Timeout
config.mailer_config=Mailer Configuration
config.task_interval=Интервал задания
config.deliver_timeout=Задержка доставки
config.mailer_config=Настройки почты
config.mailer_enabled=Включено
config.mailer_name=Имя
config.mailer_host=Сервер
config.mailer_user=Пользователь
config.oauth_config=Конфигурация OAuth
config.oauth_enabled=Включено
config.cache_config=Cache Configuration
config.cache_config=Настройки кеша
config.cache_adapter=Cache Adapter
config.cache_interval=Cache Interval
config.cache_conn=Cache Connection
@ -674,7 +674,7 @@ monitor.execute_times=Execute Times
monitor.process=Запущенные процессы
monitor.desc=Описание
monitor.start=Start Time
monitor.execute_time=Execution Time
monitor.execute_time=Время выполнения
notices.system_notice_list=Система уведомлений
notices.type=Тип

+ 1
- 1
gogs.go View File

@ -17,7 +17,7 @@ import (
"github.com/gogits/gogs/modules/setting"
)
const APP_VER = "0.5.12.0120 Beta"
const APP_VER = "0.5.12.0130 Beta"
func init() {
runtime.GOMAXPROCS(runtime.NumCPU())

+ 1
- 1
modules/base/markdown.go View File

@ -103,7 +103,7 @@ var (
MentionPattern = regexp.MustCompile(`@[0-9a-zA-Z_]{1,}`)
commitPattern = regexp.MustCompile(`(\s|^)https?.*commit/[0-9a-zA-Z]+(#+[0-9a-zA-Z-]*)?`)
issueFullPattern = regexp.MustCompile(`(\s|^)https?.*issues/[0-9]+(#+[0-9a-zA-Z-]*)?`)
issueIndexPattern = regexp.MustCompile(`#[0-9]+`)
issueIndexPattern = regexp.MustCompile(`( |^)#[0-9]+`)
sha1CurrentPattern = regexp.MustCompile(`\b[0-9a-f]{40}\b`)
)

+ 6
- 0
modules/base/template.go View File

@ -90,6 +90,11 @@ func ToUtf8(content string) string {
return res
}
// RenderCommitMessage renders commit message with XSS-safe and special links.
func RenderCommitMessage(msg, urlPrefix string) template.HTML {
return template.HTML(string(RenderIssueIndexPattern([]byte(template.HTMLEscapeString(msg)), urlPrefix)))
}
var mailDomains = map[string]string{
"gmail.com": "gmail.com",
}
@ -163,6 +168,7 @@ var TemplateFuncs template.FuncMap = map[string]interface{}{
"EscapePound": func(str string) string {
return strings.Replace(str, "#", "%23", -1)
},
"RenderCommitMessage": RenderCommitMessage,
}
type Actioner interface {

+ 2
- 2
routers/repo/commit.go View File

@ -37,7 +37,7 @@ func RenderIssueLinks(oldCommits *list.List, repoLink string) *list.List {
newCommits := list.New()
for e := oldCommits.Front(); e != nil; e = e.Next() {
c := e.Value.(*git.Commit)
c.CommitMessage = string(base.RenderIssueIndexPattern([]byte(c.CommitMessage), repoLink))
c.CommitMessage = c.CommitMessage
newCommits.PushBack(c)
}
return newCommits
@ -206,7 +206,7 @@ func Diff(ctx *middleware.Context) {
commitId := ctx.Repo.CommitId
commit := ctx.Repo.Commit
commit.CommitMessage = string(base.RenderIssueIndexPattern([]byte(commit.CommitMessage), ctx.Repo.RepoLink))
commit.CommitMessage = commit.CommitMessage
diff, err := models.GetDiffCommit(models.RepoPath(userName, repoName),
commitId, setting.Git.MaxGitDiffLines)
if err != nil {

+ 2
- 2
routers/repo/view.go View File

@ -156,9 +156,9 @@ func Home(ctx *middleware.Context) {
for _, f := range files {
switch c := f[1].(type) {
case *git.Commit:
c.CommitMessage = string(base.RenderIssueIndexPattern([]byte(c.CommitMessage), ctx.Repo.RepoLink))
c.CommitMessage = c.CommitMessage
case *git.SubModuleFile:
c.CommitMessage = string(base.RenderIssueIndexPattern([]byte(c.CommitMessage), ctx.Repo.RepoLink))
c.CommitMessage = c.CommitMessage
}
}
ctx.Data["Files"] = files

+ 1
- 1
templates/.VERSION View File

@ -1 +1 @@
0.5.12.0120 Beta
0.5.12.0130 Beta

+ 1
- 1
templates/repo/commits_table.tmpl View File

@ -32,7 +32,7 @@
{{end}}
</td>
<td class="sha"><a rel="nofollow" class="label label-green" href="{{AppSubUrl}}/{{$username}}/{{$reponame}}/commit/{{.Id}} ">{{SubStr .Id.String 0 10}} </a></td>
<td class="message"><span class="text-truncate">{{Str2html .Summary}}</span></td>
<td class="message"><span class="text-truncate">{{RenderCommitMessage .Summary $.RepoLink}}</span></td>
<td class="date">{{TimeSince .Author.When $.Lang}}</td>
</tr>
{{end}}

+ 1
- 1
templates/repo/diff.tmpl View File

@ -17,7 +17,7 @@
<div class="panel panel-info panel-radius diff-head-box">
<div class="panel-header">
<a class="pull-right btn btn-blue btn-header btn-medium btn-radius" rel="nofollow" href="{{.SourcePath}}">{{.i18n.Tr "repo.diff.browse_source"}}</a>
<h4 class="commit-message">{{Str2html .Commit.Message}}</h4>
<h4 class="commit-message">{{RenderCommitMessage .Commit.Message $.RepoLink}}</h4>
</div>
<div class="panel-body">
<span class="pull-right">

+ 1
- 1
templates/repo/view_list.tmpl View File

@ -53,7 +53,7 @@
<a rel="nofollow" class="label label-green" href="{{AppSubUrl}}/{{$.Username}}/{{$.Reponame}}/commit/{{$commit.Id}} ">{{SubStr $commit.Id.String 0 10}} </a>
</td>
<td class="message">
<span class="text-truncate">{{Str2html $commit.Summary}}</span>
<span class="text-truncate">{{RenderCommitMessage $commit.Summary $.RepoLink}}</span>
</td>
<td class="age">{{TimeSince $commit.Committer.When $.Lang}}</td>
</tr>

Loading…
Cancel
Save