Skip to content

Commit 5b20202

Browse files
committed
Merge remote-tracking branch 'giteaofficial/main'
* giteaofficial/main: Fix panic when get editor config file (go-gitea#36241) Refactor compare router param parse (go-gitea#36105) [skip ci] Updated translations via Crowdin Use flatten translation keys (go-gitea#36225) Replace CSRF cookie with `CrossOriginProtection` (go-gitea#36183) Remove fomantic form module (go-gitea#36222) Fix panic in blame view when a file has only a single commit (go-gitea#36230) fix: spelling error in migrate-storage cmd utility (go-gitea#36226) # Conflicts: # templates/user/settings/security/twofa.tmpl
2 parents 423b8ad + ff3d68b commit 5b20202

284 files changed

Lines changed: 72467 additions & 201004 deletions

File tree

Some content is hidden

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

build/update-locales.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ fi
99
mv ./options/locale/locale_en-US.json ./options/
1010

1111
# Remove translation under 25% of en_us
12-
baselines=$(wc -l "./options/locale_en-US.json" | cut -d" " -f1)
12+
baselines=$(cat "./options/locale_en-US.json" | wc -l)
1313
baselines=$((baselines / 4))
1414
for filename in ./options/locale/*.json; do
15-
lines=$(wc -l "$filename" | cut -d" " -f1)
16-
if [ $lines -lt $baselines ]; then
15+
lines=$(cat "$filename" | wc -l)
16+
if [ "$lines" -lt "$baselines" ]; then
1717
echo "Removing $filename: $lines/$baselines"
1818
rm "$filename"
1919
fi

cmd/migrate_storage.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ var CmdMigrateStorage = &cli.Command{
3636
Name: "type",
3737
Aliases: []string{"t"},
3838
Value: "",
39-
Usage: "Type of stored files to copy. Allowed types: 'attachments', 'lfs', 'avatars', 'repo-avatars', 'repo-archivers', 'packages', 'actions-log', 'actions-artifacts",
39+
Usage: "Type of stored files to copy. Allowed types: 'attachments', 'lfs', 'avatars', 'repo-avatars', 'repo-archivers', 'packages', 'actions-log', 'actions-artifacts'",
4040
},
4141
&cli.StringFlag{
4242
Name: "storage",

custom/conf/app.example.ini

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -503,9 +503,6 @@ INTERNAL_TOKEN =
503503
;; Password Hash algorithm, either "argon2", "pbkdf2", "scrypt" or "bcrypt"
504504
;PASSWORD_HASH_ALGO = pbkdf2
505505
;;
506-
;; Set false to allow JavaScript to read CSRF cookie
507-
;CSRF_COOKIE_HTTP_ONLY = true
508-
;;
509506
;; Validate against https://haveibeenpwned.com/Passwords to see if a password has been exposed
510507
;PASSWORD_CHECK_PWN = false
511508
;;

modules/git/blob_gogit.go

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,38 @@ package git
99
import (
1010
"io"
1111

12+
"code.gitea.io/gitea/modules/log"
13+
1214
"github.com/go-git/go-git/v5/plumbing"
1315
)
1416

1517
// Blob represents a Git object.
1618
type Blob struct {
17-
ID ObjectID
19+
ID ObjectID
20+
repo *Repository
21+
name string
22+
}
1823

19-
gogitEncodedObj plumbing.EncodedObject
20-
name string
24+
func (b *Blob) gogitEncodedObj() (plumbing.EncodedObject, error) {
25+
return b.repo.gogitRepo.Storer.EncodedObject(plumbing.AnyObject, plumbing.Hash(b.ID.RawValue()))
2126
}
2227

2328
// DataAsync gets a ReadCloser for the contents of a blob without reading it all.
2429
// Calling the Close function on the result will discard all unread output.
2530
func (b *Blob) DataAsync() (io.ReadCloser, error) {
26-
return b.gogitEncodedObj.Reader()
31+
obj, err := b.gogitEncodedObj()
32+
if err != nil {
33+
return nil, err
34+
}
35+
return obj.Reader()
2736
}
2837

2938
// Size returns the uncompressed size of the blob
3039
func (b *Blob) Size() int64 {
31-
return b.gogitEncodedObj.Size()
40+
obj, err := b.gogitEncodedObj()
41+
if err != nil {
42+
log.Error("Error getting gogit encoded object for blob %s(%s): %v", b.name, b.ID.String(), err)
43+
return 0
44+
}
45+
return obj.Size()
3246
}

modules/git/repo_blob.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,11 @@ func (repo *Repository) GetBlob(idStr string) (*Blob, error) {
99
if err != nil {
1010
return nil, err
1111
}
12-
return repo.getBlob(id)
12+
if id.IsZero() {
13+
return nil, ErrNotExist{id.String(), ""}
14+
}
15+
return &Blob{
16+
ID: id,
17+
repo: repo,
18+
}, nil
1319
}

modules/git/repo_blob_gogit.go

Lines changed: 0 additions & 22 deletions
This file was deleted.

modules/git/repo_blob_nogogit.go

Lines changed: 0 additions & 16 deletions
This file was deleted.

modules/git/tree_entry_gogit.go

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,9 @@ func (te *TreeEntry) Size() int64 {
5353

5454
// Blob returns the blob object the entry
5555
func (te *TreeEntry) Blob() *Blob {
56-
encodedObj, err := te.ptree.repo.gogitRepo.Storer.EncodedObject(plumbing.AnyObject, te.toGogitTreeEntry().Hash)
57-
if err != nil {
58-
return nil
59-
}
60-
6156
return &Blob{
62-
ID: te.ID,
63-
gogitEncodedObj: encodedObj,
64-
name: te.Name(),
57+
ID: te.ID,
58+
repo: te.ptree.repo,
59+
name: te.Name(),
6560
}
6661
}

modules/setting/markup.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ func newMarkupRenderer(name string, sec ConfigSection) {
255255
}
256256

257257
// ATTENTION! at the moment, only a safe set like "allow-scripts" are allowed for sandbox mode.
258-
// "allow-same-origin" should never be used, it leads to XSS attack, and it makes the JS in iframe can access parent window's config and CSRF token
258+
// "allow-same-origin" should NEVER be used, it leads to XSS attack: makes the JS in iframe can access parent window's config and send requests with user's credentials.
259259
renderContentSandbox := sec.Key("RENDER_CONTENT_SANDBOX").MustString("allow-scripts allow-popups")
260260
if renderContentSandbox == "disabled" {
261261
renderContentSandbox = ""

modules/setting/oauth2.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ func loadOAuth2From(rootCfg ConfigProvider) {
133133

134134
// FIXME: at the moment, no matter oauth2 is enabled or not, it must generate a "oauth2 JWT_SECRET"
135135
// Because this secret is also used as GeneralTokenSigningSecret (as a quick not-that-breaking fix for some legacy problems).
136-
// Including: CSRF token, account validation token, etc ...
136+
// Including: account validation token, etc ...
137137
// In main branch, the signing token should be refactored (eg: one unique for LFS/OAuth2/etc ...)
138138
jwtSecretBase64 := loadSecret(sec, "JWT_SECRET_URI", "JWT_SECRET")
139139
if InstallLock {

0 commit comments

Comments
 (0)