Skip to content

Commit 5af25ee

Browse files
committed
remove PreferredTimestampTense,AmbiguousUnicodeDetection,MaxDisplayFileSize
1 parent d675e9a commit 5af25ee

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+264
-299
lines changed

custom/conf/app.example.ini

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1286,11 +1286,9 @@ LEVEL = Info
12861286
;CODE_COMMENT_LINES = 4
12871287
;;
12881288
;; Max size of files to be displayed (default is 8MiB)
1289-
;; Deprecated in v1.24
12901289
;MAX_DISPLAY_FILE_SIZE = 8388608
12911290
;;
12921291
;; Detect ambiguous unicode characters in file contents and show warnings on the UI
1293-
;; Deprecated in v1.24
12941292
;AMBIGUOUS_UNICODE_DETECTION = true
12951293
;;
12961294
;; Whether the email of the user should be shown in the Explore Users page
@@ -1340,7 +1338,6 @@ LEVEL = Info
13401338
;;
13411339
;; The tense all timestamps should be rendered in. Possible values are `absolute` time (i.e. 1970-01-01, 11:59) and `mixed`.
13421340
;; `mixed` means most timestamps are rendered in relative time (i.e. 2 days ago).
1343-
;; Deprecated in v1.24
13441341
;PREFERRED_TIMESTAMP_TENSE = mixed
13451342

13461343
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

models/migrations/v1_24/v315.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func (s *Setting) TableName() string {
3030
}
3131

3232
func MigrateIniToDatabase(x *xorm.Engine) error {
33-
uiMap, err := util.ConfigSectionToMap(setting.UI, "ui", []string{"Reactions", "CustomEmojis"}...)
33+
uiMap, err := util.ConfigSectionToMap(setting.UI, "ui", []string{"Reactions", "CustomEmojis", "MaxDisplayFileSize", "PreferredTimestampTense", "AmbiguousUnicodeDetection"}...)
3434
if err != nil {
3535
return err
3636
}

models/migrations/v1_24/v315_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,5 @@ func Test_MigrateIniToDatabase(t *testing.T) {
2323

2424
cnt, err := x.Table("system_setting").Where("setting_key LIKE 'ui.%'").Count()
2525
assert.NoError(t, err)
26-
assert.EqualValues(t, 21, cnt)
26+
assert.EqualValues(t, 18, cnt)
2727
}

modules/charset/escape.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
package charset
99

1010
import (
11-
"context"
1211
"html/template"
1312
"io"
1413
"strings"
@@ -22,15 +21,15 @@ import (
2221
const RuneNBSP = 0xa0
2322

2423
// EscapeControlHTML escapes the unicode control sequences in a provided html document
25-
func EscapeControlHTML(ctx context.Context, html template.HTML, locale translation.Locale, allowed ...rune) (escaped *EscapeStatus, output template.HTML) {
24+
func EscapeControlHTML(html template.HTML, locale translation.Locale, allowed ...rune) (escaped *EscapeStatus, output template.HTML) {
2625
sb := &strings.Builder{}
27-
escaped, _ = EscapeControlReader(ctx, strings.NewReader(string(html)), sb, locale, allowed...) // err has been handled in EscapeControlReader
26+
escaped, _ = EscapeControlReader(strings.NewReader(string(html)), sb, locale, allowed...) // err has been handled in EscapeControlReader
2827
return escaped, template.HTML(sb.String())
2928
}
3029

3130
// EscapeControlReader escapes the unicode control sequences in a provided reader of HTML content and writer in a locale and returns the findings as an EscapeStatus
32-
func EscapeControlReader(ctx context.Context, reader io.Reader, writer io.Writer, locale translation.Locale, allowed ...rune) (escaped *EscapeStatus, err error) {
33-
if !setting.Config().UI.AmbiguousUnicodeDetection.Value(ctx) {
31+
func EscapeControlReader(reader io.Reader, writer io.Writer, locale translation.Locale, allowed ...rune) (escaped *EscapeStatus, err error) {
32+
if !setting.UI.AmbiguousUnicodeDetection {
3433
_, err = io.Copy(writer, reader)
3534
return &EscapeStatus{}, err
3635
}

modules/charset/escape_test.go

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"testing"
1010

1111
"code.gitea.io/gitea/modules/setting"
12-
"code.gitea.io/gitea/modules/setting/config"
1312
"code.gitea.io/gitea/modules/test"
1413
"code.gitea.io/gitea/modules/translation"
1514

@@ -162,7 +161,7 @@ func TestEscapeControlReader(t *testing.T) {
162161
for _, tt := range tests {
163162
t.Run(tt.name, func(t *testing.T) {
164163
output := &strings.Builder{}
165-
status, err := EscapeControlReader(t.Context(), strings.NewReader(tt.text), output, &translation.MockLocale{})
164+
status, err := EscapeControlReader(strings.NewReader(tt.text), output, &translation.MockLocale{})
166165
assert.NoError(t, err)
167166
assert.Equal(t, tt.status, *status)
168167
outStr := output.String()
@@ -173,12 +172,10 @@ func TestEscapeControlReader(t *testing.T) {
173172
}
174173

175174
func TestSettingAmbiguousUnicodeDetection(t *testing.T) {
176-
ambiguousUnicodeDetectionValue := setting.Config().UI.AmbiguousUnicodeDetection.Value(t.Context())
177-
defer test.MockVariableValue(&ambiguousUnicodeDetectionValue, true)()
178-
_, out := EscapeControlHTML(t.Context(), "a test", &translation.MockLocale{})
175+
defer test.MockVariableValue(&setting.UI.AmbiguousUnicodeDetection, true)()
176+
_, out := EscapeControlHTML("a test", &translation.MockLocale{})
179177
assert.EqualValues(t, `a<span class="escaped-code-point" data-escaped="[U+00A0]"><span class="char"> </span></span>test`, out)
180-
ambiguousUnicodeDetection := config.Value[bool]{}
181-
setting.Config().UI.AmbiguousUnicodeDetection = ambiguousUnicodeDetection.WithDefault(false)
182-
_, out = EscapeControlHTML(t.Context(), "a test", &translation.MockLocale{})
178+
setting.UI.AmbiguousUnicodeDetection = false
179+
_, out = EscapeControlHTML("a test", &translation.MockLocale{})
183180
assert.EqualValues(t, `a test`, out)
184181
}

modules/issue/template/unmarshal.go

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
package template
55

66
import (
7-
"context"
87
"fmt"
98
"io"
109
"path"
@@ -43,31 +42,31 @@ func Unmarshal(filename string, content []byte) (*api.IssueTemplate, error) {
4342
}
4443

4544
// UnmarshalFromEntry parses out a valid template from the blob in entry
46-
func UnmarshalFromEntry(ctx context.Context, entry *git.TreeEntry, dir string) (*api.IssueTemplate, error) {
47-
return unmarshalFromEntry(ctx, entry, path.Join(dir, entry.Name())) // Filepaths in Git are ALWAYS '/' separated do not use filepath here
45+
func UnmarshalFromEntry(entry *git.TreeEntry, dir string) (*api.IssueTemplate, error) {
46+
return unmarshalFromEntry(entry, path.Join(dir, entry.Name())) // Filepaths in Git are ALWAYS '/' separated do not use filepath here
4847
}
4948

5049
// UnmarshalFromCommit parses out a valid template from the commit
51-
func UnmarshalFromCommit(ctx context.Context, commit *git.Commit, filename string) (*api.IssueTemplate, error) {
50+
func UnmarshalFromCommit(commit *git.Commit, filename string) (*api.IssueTemplate, error) {
5251
entry, err := commit.GetTreeEntryByPath(filename)
5352
if err != nil {
5453
return nil, fmt.Errorf("get entry for %q: %w", filename, err)
5554
}
56-
return unmarshalFromEntry(ctx, entry, filename)
55+
return unmarshalFromEntry(entry, filename)
5756
}
5857

5958
// UnmarshalFromRepo parses out a valid template from the head commit of the branch
60-
func UnmarshalFromRepo(ctx context.Context, repo *git.Repository, branch, filename string) (*api.IssueTemplate, error) {
59+
func UnmarshalFromRepo(repo *git.Repository, branch, filename string) (*api.IssueTemplate, error) {
6160
commit, err := repo.GetBranchCommit(branch)
6261
if err != nil {
6362
return nil, fmt.Errorf("get commit on branch %q: %w", branch, err)
6463
}
6564

66-
return UnmarshalFromCommit(ctx, commit, filename)
65+
return UnmarshalFromCommit(commit, filename)
6766
}
6867

69-
func unmarshalFromEntry(ctx context.Context, entry *git.TreeEntry, filename string) (*api.IssueTemplate, error) {
70-
if size := entry.Blob().Size(); size > setting.Config().UI.MaxDisplayFileSize.Value(ctx) {
68+
func unmarshalFromEntry(entry *git.TreeEntry, filename string) (*api.IssueTemplate, error) {
69+
if size := entry.Blob().Size(); size > setting.UI.MaxDisplayFileSize {
7170
return nil, fmt.Errorf("too large: %v > MaxDisplayFileSize", size)
7271
}
7372

modules/markup/markdown/markdown.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ func render(ctx *markup.RenderContext, input io.Reader, output io.Writer) error
156156
converter := SpecializedMarkdown(ctx)
157157
lw := &limitWriter{
158158
w: output,
159-
limit: setting.Config().UI.MaxDisplayFileSize.Value(ctx) * 3,
159+
limit: setting.UI.MaxDisplayFileSize * 3,
160160
}
161161

162162
// FIXME: should we include a timeout to abort the renderer if it takes too long?

0 commit comments

Comments
 (0)