Skip to content

Commit

Permalink
Merge branch 'main' into fix-3796-add-reindex-button-to-settings
Browse files Browse the repository at this point in the history
  • Loading branch information
wxiaoguang authored Dec 16, 2021
2 parents 423c69e + e78ee73 commit ed39a86
Show file tree
Hide file tree
Showing 11 changed files with 42 additions and 44 deletions.
17 changes: 8 additions & 9 deletions modules/markup/html.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ func postProcess(ctx *RenderContext, procs []processor, input io.Reader, output
node = node.FirstChild
}

visitNode(ctx, procs, node, true)
visitNode(ctx, procs, procs, node)

newNodes := make([]*html.Node, 0, 5)

Expand Down Expand Up @@ -354,24 +354,22 @@ func postProcess(ctx *RenderContext, procs []processor, input io.Reader, output
return nil
}

func visitNode(ctx *RenderContext, procs []processor, node *html.Node, visitText bool) {
func visitNode(ctx *RenderContext, procs, textProcs []processor, node *html.Node) {
// Add user-content- to IDs if they don't already have them
for idx, attr := range node.Attr {
if attr.Key == "id" && !(strings.HasPrefix(attr.Val, "user-content-") || blackfridayExtRegex.MatchString(attr.Val)) {
node.Attr[idx].Val = "user-content-" + attr.Val
}

if attr.Key == "class" && attr.Val == "emoji" {
visitText = false
textProcs = nil
}
}

// We ignore code, pre and already generated links.
// We ignore code and pre.
switch node.Type {
case html.TextNode:
if visitText {
textNode(ctx, procs, node)
}
textNode(ctx, textProcs, node)
case html.ElementNode:
if node.Data == "img" {
for i, attr := range node.Attr {
Expand All @@ -390,7 +388,8 @@ func visitNode(ctx *RenderContext, procs []processor, node *html.Node, visitText
node.Attr[i] = attr
}
} else if node.Data == "a" {
visitText = false
// Restrict text in links to emojis
textProcs = emojiProcessors
} else if node.Data == "code" || node.Data == "pre" {
return
} else if node.Data == "i" {
Expand All @@ -416,7 +415,7 @@ func visitNode(ctx *RenderContext, procs []processor, node *html.Node, visitText
}
}
for n := node.FirstChild; n != nil; n = n.NextSibling {
visitNode(ctx, procs, n, visitText)
visitNode(ctx, procs, textProcs, n)
}
}
// ignore everything else
Expand Down
8 changes: 8 additions & 0 deletions modules/markup/markdown/markdown_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -391,5 +391,13 @@ func TestRenderSiblingImages_Issue12925(t *testing.T) {
res, err := RenderRawString(&markup.RenderContext{}, testcase)
assert.NoError(t, err)
assert.Equal(t, expected, res)
}

func TestRenderEmojiInLinks_Issue12331(t *testing.T) {
testcase := `[Link with emoji :moon: in text](https://gitea.io)`
expected := `<p><a href="https://gitea.io" rel="nofollow">Link with emoji <span class="emoji" aria-label="waxing gibbous moon">🌔</span> in text</a></p>
`
res, err := RenderString(&markup.RenderContext{}, testcase)
assert.NoError(t, err)
assert.Equal(t, expected, res)
}
4 changes: 0 additions & 4 deletions options/locale/locale_de-DE.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1210,11 +1210,7 @@ issues.action_milestone_no_select=Kein Meilenstein
issues.action_assignee=Zuständig
issues.action_assignee_no_select=Niemand zuständig
issues.opened_by=%[1]s von <a href="%[2]s">%[3]s</a> geöffnet
pulls.merged_by=%[1]s gemergt von <a href="%[2]s">%[3]s</a>
pulls.merged_by_fake=%[1]s gemergt von %[2]s
issues.closed_by=%[1]s geschlossen von <a href="%[2]s">%[3]s</a>
issues.opened_by_fake=%[1]s geöffnet von %[2]s
issues.closed_by_fake=%[1]s geschlossen von %[2]s
issues.previous=Vorherige
issues.next=Nächste
issues.open_title=Offen
Expand Down
4 changes: 0 additions & 4 deletions options/locale/locale_el-GR.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1204,11 +1204,7 @@ issues.action_milestone_no_select=Χωρίς ορόσημο
issues.action_assignee=Αποδέκτης
issues.action_assignee_no_select=Κανένας Αποδέκτης
issues.opened_by=άνοιξαν %[1]s από <a href="%[2]s">%[3]s</a>
pulls.merged_by=συγχώνευσε το %[1]s από <a href="%[2]s">%[3]s</a>
pulls.merged_by_fake=συγχώνευσε το %[1]s από %[2]s
issues.closed_by=έκλεισε το %[1]s από <a href="%[2]s">%[3]s</a>
issues.opened_by_fake=άνοιξε το %[1]s από %[2]s
issues.closed_by_fake=έκλεισε το %[1]s από %[2]s
issues.previous=Προηγούμενο
issues.next=Επόμενο
issues.open_title=Ανοιχτό
Expand Down
4 changes: 0 additions & 4 deletions options/locale/locale_es-ES.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1221,11 +1221,7 @@ issues.action_milestone_no_select=Sin hito
issues.action_assignee=Asignado a
issues.action_assignee_no_select=Sin asignado
issues.opened_by=abierta %[1]s por <a href="%[2]s">%[3]s</a>
pulls.merged_by=fusionado %[1]s por <a href="%[2]s">%[3]s</a>
pulls.merged_by_fake=fusionado %[1]s por %[2]s
issues.closed_by=cerrada %[1]s por <a href="%[2]s">%[3]s</a>
issues.opened_by_fake=abierta %[1]s por %[2]s
issues.closed_by_fake=cerrada %[1]s por %[2]s
issues.previous=Página Anterior
issues.next=Página Siguiente
issues.open_title=Abierta
Expand Down
4 changes: 0 additions & 4 deletions options/locale/locale_ja-JP.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1223,11 +1223,7 @@ issues.action_milestone_no_select=マイルストーンなし
issues.action_assignee=担当者
issues.action_assignee_no_select=担当者なし
issues.opened_by=<a href="%[2]s">%[3]s</a>が%[1]sに作成
pulls.merged_by=<a href="%[2]s">%[3]s</a>が%[1]sにマージ
pulls.merged_by_fake=%[2]sが%[1]sにマージ
issues.closed_by=<a href="%[2]s">%[3]s</a>が%[1]sにクローズ
issues.opened_by_fake=%[2]sが%[1]sに作成
issues.closed_by_fake=%[2]sが%[1]sにクローズ
issues.previous=前ページ
issues.next=次ページ
issues.open_title=オープン
Expand Down
14 changes: 10 additions & 4 deletions options/locale/locale_pt-PT.ini
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,7 @@ lang_select_error=Escolha um idioma da lista.
username_been_taken=O nome de utilizador já foi tomado.
username_change_not_local_user=Utilizadores que não são locais não têm permissão para mudar o nome de utilizador.
repo_name_been_taken=O nome do repositório já foi usado.
repository_force_private=Forçar Privado está habilitado: repositórios privados não podem ser tornados públicos.
repository_files_already_exist=Já existem ficheiros neste repositório. Contacte o administrador do sistema.
repository_files_already_exist.adopt=Já existem ficheiros neste repositório e só podem ser adoptados.
repository_files_already_exist.delete=Já existem ficheiros neste repositório. Tem que os eliminar.
Expand Down Expand Up @@ -1224,11 +1225,11 @@ issues.action_milestone_no_select=Sem etapa
issues.action_assignee=Responsável
issues.action_assignee_no_select=Sem responsável
issues.opened_by=aberta %[1]s por <a href="%[2]s">%[3]s</a>
pulls.merged_by=%[1]s executado(s) por <a href="%[2]s">%[3]s</a>
pulls.merged_by_fake=%[1]s executado(s) por %[2]s
issues.closed_by=%[1]s resolvida(s) por <a href="%[2]s">%[3]s</a>
pulls.merged_by=por <a href="%[2]s">%[3]s</a> foi executado %[1]s
pulls.merged_by_fake=por %[2]s foi executado %[1]s
issues.closed_by=por <a href="%[2]s">%[3]s</a> foi fechada %[1]s
issues.opened_by_fake=%[1]s aberta(s) por %[2]s
issues.closed_by_fake=%[1]s resolvida(s) por %[2]s
issues.closed_by_fake=por %[2]s foi fechada %[1]s
issues.previous=Anterior
issues.next=Seguinte
issues.open_title=Aberta
Expand Down Expand Up @@ -2516,6 +2517,11 @@ auths.oauth2_emailURL=URL do email
auths.skip_local_two_fa=Ignorar a autenticação em dois passos local
auths.skip_local_two_fa_helper=Deixar esta opção desligada faz com que os utilizadores locais que tenham a autenticação em dois passos habilitada sejam obrigados a passar por ela para iniciar a sessão
auths.oauth2_tenant=Locatário
auths.oauth2_scopes=Âmbitos adicionais
auths.oauth2_required_claim_name=Nome de Reivindicação obrigatório
auths.oauth2_required_claim_name_helper=Defina este nome para restringir o início de sessão desta fonte a utilizadores que tenham uma reivindicação com este nome
auths.oauth2_required_claim_value=Valor de Reivindicação obrigatório
auths.oauth2_required_claim_value_helper=Defina este valor para restringir o início de sessão desta fonte a utilizadores que tenham uma reivindicação com este nome e este valor
auths.enable_auto_register=Habilitar o registo automático
auths.sspi_auto_create_users=Criar utilizadores automaticamente
auths.sspi_auto_create_users_helper=Permitir que o método de autenticação SSPI crie, automaticamente, novas contas para utilizadores que iniciam a sessão pela primeira vez
Expand Down
4 changes: 0 additions & 4 deletions options/locale/locale_ru-RU.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1210,11 +1210,7 @@ issues.action_milestone_no_select=Нет этапа
issues.action_assignee=Ответственный
issues.action_assignee_no_select=Нет ответственного
issues.opened_by=открыта %[1]s <a href="%[2]s">%[3]s</a>
pulls.merged_by=слито %[1]s пользователем <a href="%[2]s">%[3]s</a>
pulls.merged_by_fake=слито %[1]s пользователем %[2]s
issues.closed_by=закрыт %[1]s пользователем <a href="%[2]s">%[3]s</a>
issues.opened_by_fake=открыт %[1]s пользователем %[2]s
issues.closed_by_fake=закрыт %[1]s пользователем %[2]s
issues.previous=Предыдущая
issues.next=Следующая
issues.open_title=Открыто
Expand Down
3 changes: 0 additions & 3 deletions options/locale/locale_tr-TR.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1188,10 +1188,7 @@ issues.action_milestone_no_select=Kilometre Taşı Yok
issues.action_assignee=Atanan
issues.action_assignee_no_select=Atanan yok
issues.opened_by=<a href="%[2]s">%[3]s</a> tarafından %[1]s açıldı
pulls.merged_by_fake=%[2]s tarafından %[1]s birleştirildi
issues.closed_by=<a href="%[2]s">%[3]s</a> tarafından %[1]s kapatıldı
issues.opened_by_fake=%[2]s tarafından %[1]s açıldı
issues.closed_by_fake=%[2]s tarafından %[1]s kapatıldı
issues.previous=Önceki
issues.next=Sonraki
issues.open_title=Açık
Expand Down
14 changes: 10 additions & 4 deletions options/locale/locale_zh-CN.ini
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,7 @@ lang_select_error=从列表中选出语言
username_been_taken=用户名已被使用。
username_change_not_local_user=非本地用户不允许更改用户名。
repo_name_been_taken=仓库名称已被使用。
repository_force_private=“强制私有”已启用:私有仓库不能被公开。
repository_files_already_exist=此仓库已存在文件。请联系系统管理员。
repository_files_already_exist.adopt=此仓库已存在文件,只能被收录。
repository_files_already_exist.delete=此仓库已存在文件,必须先删除他们。
Expand Down Expand Up @@ -1225,11 +1226,11 @@ issues.action_milestone_no_select=无里程碑
issues.action_assignee=指派人筛选
issues.action_assignee_no_select=未指派
issues.opened_by=由 <a href="%[2]s">%[3]s</a> 于 %[1]s创建
pulls.merged_by=由 <a href="%[2]s">%[3]s</a> %[1]s 合并
pulls.merged_by_fake=由 %[2]s %[1]s 合并
issues.closed_by=由 <a href="%[2]s">%[3]s</a> %[1]s 关闭
pulls.merged_by=由 <a href="%[2]s">%[3]s</a> 创建,被合并于 %[1]s
pulls.merged_by_fake=由 %[2]s 创建,被合并于 %[1]s
issues.closed_by=由 <a href="%[2]s">%[3]s</a> 创建,被关闭于 %[1]s
issues.opened_by_fake=由 %[2]s 于 %[1]s 打开
issues.closed_by_fake=由 %[2]s %[1]s 关闭
issues.closed_by_fake=由 %[2]s 创建,被关闭于 %[1]s
issues.previous=上一页
issues.next=下一页
issues.open_title=开启中
Expand Down Expand Up @@ -2520,6 +2521,11 @@ auths.oauth2_emailURL=电子邮件 URL
auths.skip_local_two_fa=跳过本地两步验证
auths.skip_local_two_fa_helper=不设置意味着设置了两步验证的本地用户仍然需要通过两步验证才能登录
auths.oauth2_tenant=租户
auths.oauth2_scopes=附加授权范围(Scopes)
auths.oauth2_required_claim_name=必须填写 Claim 声明的名称
auths.oauth2_required_claim_name_helper=设置此名称,只有具有此名称的声明(Claim)的用户可从此源登录
auths.oauth2_required_claim_value=必须填写 Claim 声明的值
auths.oauth2_required_claim_value_helper=设置此值,只有拥有对应的声明(Claim)的名称和值的用户才被允许从此源登录
auths.enable_auto_register=允许用户自动注册
auths.sspi_auto_create_users=自动创建用户
auths.sspi_auto_create_users_helper=允许 SSPI 认证在用户第一次登录时自动创建新账号
Expand Down
10 changes: 6 additions & 4 deletions options/locale/locale_zh-TW.ini
Original file line number Diff line number Diff line change
Expand Up @@ -785,6 +785,8 @@ visibility_fork_helper=(修改本值將會影響所有 fork 儲存庫)
clone_helper=需要有關 Clone 的協助嗎?查看<a target="_blank" rel="noopener noreferrer" href="%s">幫助</a> 。
fork_repo=Fork 儲存庫
fork_from=Fork 自
already_forked=您已經 fork 過 %s
fork_to_different_account=Fork 到其他帳戶
fork_visibility_helper=無法更改 fork 儲存庫的瀏覽權限。
use_template=使用此範本
clone_in_vsc=在 VS Code 中 Clone
Expand Down Expand Up @@ -1223,11 +1225,11 @@ issues.action_milestone_no_select=無里程碑
issues.action_assignee=成員
issues.action_assignee_no_select=沒有成員
issues.opened_by=建立於 %[1]s 由 <a href="%[2]s">%[3]s</a>
pulls.merged_by=合併於 %[1]s,由 <a href="%[2]s">%[3]s</a> 建立
pulls.merged_by_fake=合併於 %[1]s,由 %[2]s 建立
issues.closed_by=關閉於 %[1]s,由 <a href="%[2]s">%[3]s</a> 建立
pulls.merged_by=由 <a href="%[2]s">%[3]s</a> 建立,合併於 %[1]s
pulls.merged_by_fake= %[2]s 建立,合併於 %[1]s
issues.closed_by=由 <a href="%[2]s">%[3]s</a> 建立,關閉於 %[1]s
issues.opened_by_fake=建立於 %[1]s 由 %[2]s
issues.closed_by_fake=關閉於 %[1]s,由 %[2]s 建立
issues.closed_by_fake= %[2]s 建立,關閉於 %[1]s
issues.previous=上一頁
issues.next=下一頁
issues.open_title=開放中
Expand Down

0 comments on commit ed39a86

Please sign in to comment.