From 89e414485585c65a04ffd61a83eebbaf4897559c Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Wed, 9 Apr 2025 15:52:01 +0800 Subject: [PATCH 1/5] Set MERMAID_MAX_SOURCE_CHARACTERS to 50000 (#34152) Fix #32015 (cherry picked from commit f8edc29f5dd1a99e3be1a2ff764d1d7315862345) --- custom/conf/app.example.ini | 2 +- modules/setting/markup.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/custom/conf/app.example.ini b/custom/conf/app.example.ini index 11c5d5eb0a..5069c7ec95 100644 --- a/custom/conf/app.example.ini +++ b/custom/conf/app.example.ini @@ -2444,7 +2444,7 @@ LEVEL = Info ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Set the maximum number of characters in a mermaid source. (Set to -1 to disable limits) -;MERMAID_MAX_SOURCE_CHARACTERS = 5000 +;MERMAID_MAX_SOURCE_CHARACTERS = 50000 ;; Set the maximum number of lines allowed for a filepreview. (Set to -1 to disable limits; set to 0 to disable the feature) ;FILEPREVIEW_MAX_LINES = 50 diff --git a/modules/setting/markup.go b/modules/setting/markup.go index 90fc86b131..4ab9e7b2d1 100644 --- a/modules/setting/markup.go +++ b/modules/setting/markup.go @@ -62,7 +62,7 @@ type MarkupSanitizerRule struct { func loadMarkupFrom(rootCfg ConfigProvider) { mustMapSetting(rootCfg, "markdown", &Markdown) - MermaidMaxSourceCharacters = rootCfg.Section("markup").Key("MERMAID_MAX_SOURCE_CHARACTERS").MustInt(5000) + MermaidMaxSourceCharacters = rootCfg.Section("markup").Key("MERMAID_MAX_SOURCE_CHARACTERS").MustInt(50000) FilePreviewMaxLines = rootCfg.Section("markup").Key("FILEPREVIEW_MAX_LINES").MustInt(50) ExternalMarkupRenderers = make([]*MarkupRenderer, 0, 10) ExternalSanitizerRules = make([]MarkupSanitizerRule, 0, 10) From 23b713464cfd13d5fc5902bac8b8ee3c3967ea29 Mon Sep 17 00:00:00 2001 From: ManInDark <61268856+ManInDark@users.noreply.github.com> Date: Wed, 9 Apr 2025 21:21:54 +0200 Subject: [PATCH 2/5] bugfix check for alternate ssh host certificate location (#34146) fixes #34145 Edited all locations to actually be correct. --------- Co-authored-by: wxiaoguang Co-authored-by: Giteabot (cherry picked from commit fac6b87dd24be5021d9c656edc2072397cfd6bed) --- docker/root/etc/s6/openssh/setup | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/docker/root/etc/s6/openssh/setup b/docker/root/etc/s6/openssh/setup index 6fbc599cc5..48e7d4b211 100755 --- a/docker/root/etc/s6/openssh/setup +++ b/docker/root/etc/s6/openssh/setup @@ -31,16 +31,19 @@ if [ -e /data/ssh/ssh_host_ecdsa_cert ]; then SSH_ECDSA_CERT=${SSH_ECDSA_CERT:-"/data/ssh/ssh_host_ecdsa_cert"} fi -if [ -e /data/ssh/ssh_host_ed25519-cert.pub ]; then - SSH_ED25519_CERT=${SSH_ED25519_CERT:-"/data/ssh/ssh_host_ed25519-cert.pub"} +# In case someone wants to sign the `{keyname}.pub` key by `ssh-keygen -s ca -I identity ...` to +# make use of the ssh-key certificate authority feature (see ssh-keygen CERTIFICATES section), +# the generated key file name is `{keyname}-cert.pub` +if [ -e /data/ssh/ssh_host_ed25519_key-cert.pub ]; then + SSH_ED25519_CERT=${SSH_ED25519_CERT:-"/data/ssh/ssh_host_ed25519_key-cert.pub"} fi -if [ -e /data/ssh/ssh_host_rsa-cert.pub ]; then - SSH_RSA_CERT=${SSH_RSA_CERT:-"/data/ssh/ssh_host_rsa-cert.pub"} +if [ -e /data/ssh/ssh_host_rsa_key-cert.pub ]; then + SSH_RSA_CERT=${SSH_RSA_CERT:-"/data/ssh/ssh_host_rsa_key-cert.pub"} fi -if [ -e /data/ssh/ssh_host_ecdsa-cert.pub ]; then - SSH_ECDSA_CERT=${SSH_ECDSA_CERT:-"/data/ssh/ssh_host_ecdsa-cert.pub"} +if [ -e /data/ssh/ssh_host_ecdsa_key-cert.pub ]; then + SSH_ECDSA_CERT=${SSH_ECDSA_CERT:-"/data/ssh/ssh_host_ecdsa_key-cert.pub"} fi if [ -d /etc/ssh ]; then From 9144726e4f816525a47024f135958c5234547836 Mon Sep 17 00:00:00 2001 From: Kerwin Bryant Date: Sat, 12 Apr 2025 11:34:42 +0800 Subject: [PATCH 3/5] Update milestones.tmpl (#34184) (cherry picked from commit 5015992db578659a47b9a0949f1773ebac2b2b4b) --- templates/user/dashboard/milestones.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/user/dashboard/milestones.tmpl b/templates/user/dashboard/milestones.tmpl index b269c63b37..01dcbec1c9 100644 --- a/templates/user/dashboard/milestones.tmpl +++ b/templates/user/dashboard/milestones.tmpl @@ -114,7 +114,7 @@ {{ctx.Locale.Tr "repo.milestones.closed" $closedDate}} {{else}} {{if .DeadlineString}} - + {{svg "octicon-calendar" 14}} {{DateUtils.AbsoluteShort (.DeadlineString|DateUtils.ParseLegacy)}} From 82dd00873d3c20ac875eb4ec120a8c58721c6760 Mon Sep 17 00:00:00 2001 From: hiifong Date: Sun, 13 Apr 2025 10:24:32 +0800 Subject: [PATCH 4/5] fix webhook url (#34186) Co-authored-by: wxiaoguang (cherry picked from commit aada0370e7d72a591d58788f6db76bdbc3dddbb7) --- models/webhook/webhook_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/webhook/webhook_test.go b/models/webhook/webhook_test.go index 7f0abbd8bb..e70c3b2557 100644 --- a/models/webhook/webhook_test.go +++ b/models/webhook/webhook_test.go @@ -91,7 +91,7 @@ func TestWebhook_EventsArray(t *testing.T) { func TestCreateWebhook(t *testing.T) { hook := &Webhook{ RepoID: 3, - URL: "www.example.com/unit_test", + URL: "https://www.example.com/unit_test", ContentType: ContentTypeJSON, Events: `{"push_only":false,"send_everything":false,"choose_events":false,"events":{"create":false,"push":true,"pull_request":true}}`, } From 504bb09319eaa30bee6e2416737c6c75225897a0 Mon Sep 17 00:00:00 2001 From: TheFox0x7 Date: Mon, 14 Apr 2025 01:20:14 +0200 Subject: [PATCH 5/5] fix github migration error when using multiple tokens (#34144) Git authorization was not taking into account multiple token feature, leading to auth failures Closes: https://github.com/go-gitea/gitea/issues/34141 --------- Co-authored-by: wxiaoguang (cherry picked from commit 8a6df00c532becd4d10efb70827ccf80b2bf74e2) --- services/migrations/github.go | 17 ++++++++++++++- services/migrations/github_test.go | 33 ++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/services/migrations/github.go b/services/migrations/github.go index 5052a68114..9721c86180 100644 --- a/services/migrations/github.go +++ b/services/migrations/github.go @@ -140,7 +140,7 @@ func (g *GithubDownloaderV3) LogString() string { func (g *GithubDownloaderV3) addClient(client *http.Client, baseURL string) { githubClient := github.NewClient(client) if baseURL != "https://github.com" { - githubClient, _ = github.NewClient(client).WithEnterpriseURLs(baseURL, baseURL) + githubClient, _ = githubClient.WithEnterpriseURLs(baseURL, baseURL) } g.clients = append(g.clients, githubClient) g.rates = append(g.rates, nil) @@ -885,3 +885,18 @@ func (g *GithubDownloaderV3) GetReviews(reviewable base.Reviewable) ([]*base.Rev } return allReviews, nil } + +// FormatCloneURL add authentication into remote URLs +func (g *GithubDownloaderV3) FormatCloneURL(opts MigrateOptions, remoteAddr string) (string, error) { + u, err := url.Parse(remoteAddr) + if err != nil { + return "", err + } + if len(opts.AuthToken) > 0 { + // "multiple tokens" are used to benefit more "API rate limit quota" + // git clone doesn't count for rate limits, so only use the first token. + // source: https://github.com/orgs/community/discussions/44515 + u.User = url.UserPassword("oauth2", strings.Split(opts.AuthToken, ",")[0]) + } + return u.String(), nil +} diff --git a/services/migrations/github_test.go b/services/migrations/github_test.go index b1f20c4716..c5e24ebbcd 100644 --- a/services/migrations/github_test.go +++ b/services/migrations/github_test.go @@ -433,3 +433,36 @@ func TestGitHubDownloadRepo(t *testing.T) { }, }, reviews) } + +func TestGithubMultiToken(t *testing.T) { + testCases := []struct { + desc string + token string + expectedCloneURL string + }{ + { + desc: "Single Token", + token: "single_token", + expectedCloneURL: "https://oauth2:single_token@github.com", + }, + { + desc: "Multi Token", + token: "token1,token2", + expectedCloneURL: "https://oauth2:token1@github.com", + }, + } + factory := GithubDownloaderV3Factory{} + + for _, tC := range testCases { + t.Run(tC.desc, func(t *testing.T) { + opts := base.MigrateOptions{CloneAddr: "https://github.com/go-gitea/gitea", AuthToken: tC.token} + client, err := factory.New(t.Context(), opts) + require.NoError(t, err) + + cloneURL, err := client.FormatCloneURL(opts, "https://github.com") + require.NoError(t, err) + + assert.Equal(t, tC.expectedCloneURL, cloneURL) + }) + } +}