Skip to content

Commit 4726608

Browse files
authored
Merge branch 'main' into foldable-folders
2 parents ab887b3 + 51ab495 commit 4726608

File tree

6 files changed

+15
-9
lines changed

6 files changed

+15
-9
lines changed

Diff for: .golangci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ linters:
2828
fast: false
2929

3030
run:
31-
go: 1.20
31+
go: "1.20"
3232
timeout: 10m
3333
skip-dirs:
3434
- node_modules

Diff for: models/db/sql_postgres_with_schema.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ func (d *postgresSchemaDriver) Open(name string) (driver.Conn, error) {
3737
}
3838
schemaValue, _ := driver.String.ConvertValue(setting.Database.Schema)
3939

40-
if execer, ok := conn.(driver.Execer); ok {
40+
// golangci lint is incorrect here - there is no benefit to using driver.ExecerContext here
41+
// and in any case pq does not implement it
42+
if execer, ok := conn.(driver.Execer); ok { //nolint
4143
_, err := execer.Exec(`SELECT set_config(
4244
'search_path',
4345
$1 || ',' || current_setting('search_path'),
@@ -61,7 +63,8 @@ func (d *postgresSchemaDriver) Open(name string) (driver.Conn, error) {
6163

6264
// driver.String.ConvertValue will never return err for string
6365

64-
_, err = stmt.Exec([]driver.Value{schemaValue})
66+
// golangci lint is incorrect here - there is no benefit to using stmt.ExecWithContext here
67+
_, err = stmt.Exec([]driver.Value{schemaValue}) //nolint
6568
if err != nil {
6669
_ = conn.Close()
6770
return nil, err

Diff for: modules/lfs/endpoint.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
package lfs
55

66
import (
7-
"fmt"
87
"net/url"
98
"os"
109
"path"
1110
"path/filepath"
1211
"strings"
1312

1413
"code.gitea.io/gitea/modules/log"
14+
"code.gitea.io/gitea/modules/util"
1515
)
1616

1717
// DetermineEndpoint determines an endpoint from the clone url or uses the specified LFS url.
@@ -95,7 +95,7 @@ func endpointFromLocalPath(path string) *url.URL {
9595
return nil
9696
}
9797

98-
path = fmt.Sprintf("file://%s%s", slash, filepath.ToSlash(path))
98+
path = "file://" + slash + util.PathEscapeSegments(filepath.ToSlash(path))
9999

100100
u, _ := url.Parse(path)
101101

Diff for: services/repository/files/content.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"code.gitea.io/gitea/modules/git"
1616
"code.gitea.io/gitea/modules/setting"
1717
api "code.gitea.io/gitea/modules/structs"
18+
"code.gitea.io/gitea/modules/util"
1819
)
1920

2021
// ContentType repo content type
@@ -158,7 +159,7 @@ func GetContents(ctx context.Context, repo *repo_model.Repository, treePath, ref
158159
return nil, fmt.Errorf("no commit found for the ref [ref: %s]", ref)
159160
}
160161

161-
selfURL, err := url.Parse(fmt.Sprintf("%s/contents/%s?ref=%s", repo.APIURL(), treePath, origRef))
162+
selfURL, err := url.Parse(repo.APIURL() + "/contents/" + util.PathEscapeSegments(treePath) + "?ref=" + url.QueryEscape(origRef))
162163
if err != nil {
163164
return nil, err
164165
}
@@ -217,23 +218,23 @@ func GetContents(ctx context.Context, repo *repo_model.Repository, treePath, ref
217218
}
218219
// Handle links
219220
if entry.IsRegular() || entry.IsLink() {
220-
downloadURL, err := url.Parse(fmt.Sprintf("%s/raw/%s/%s/%s", repo.HTMLURL(), refType, ref, treePath))
221+
downloadURL, err := url.Parse(repo.HTMLURL() + "/raw/" + url.PathEscape(string(refType)) + "/" + util.PathEscapeSegments(ref) + "/" + util.PathEscapeSegments(treePath))
221222
if err != nil {
222223
return nil, err
223224
}
224225
downloadURLString := downloadURL.String()
225226
contentsResponse.DownloadURL = &downloadURLString
226227
}
227228
if !entry.IsSubModule() {
228-
htmlURL, err := url.Parse(fmt.Sprintf("%s/src/%s/%s/%s", repo.HTMLURL(), refType, ref, treePath))
229+
htmlURL, err := url.Parse(repo.HTMLURL() + "/src/" + url.PathEscape(string(refType)) + "/" + util.PathEscapeSegments(ref) + "/" + util.PathEscapeSegments(treePath))
229230
if err != nil {
230231
return nil, err
231232
}
232233
htmlURLString := htmlURL.String()
233234
contentsResponse.HTMLURL = &htmlURLString
234235
contentsResponse.Links.HTMLURL = &htmlURLString
235236

236-
gitURL, err := url.Parse(fmt.Sprintf("%s/git/blobs/%s", repo.APIURL(), entry.ID.String()))
237+
gitURL, err := url.Parse(repo.APIURL() + "/git/blobs/" + url.PathEscape(entry.ID.String()))
237238
if err != nil {
238239
return nil, err
239240
}

Diff for: web_src/less/_base.less

+1
Original file line numberDiff line numberDiff line change
@@ -1803,6 +1803,7 @@ footer {
18031803
}
18041804
}
18051805

1806+
/* TODO: remove in favor of .hidden helper */
18061807
.hide {
18071808
display: none;
18081809

Diff for: web_src/less/helpers.less

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
/* below class names match Tailwind CSS */
2323
.pointer-events-none { pointer-events: none !important; }
2424
.relative { position: relative !important; }
25+
.hidden { display: none !important; }
2526

2627
.mono {
2728
font-family: var(--fonts-monospace) !important;

0 commit comments

Comments
 (0)