Skip to content

Commit 77ff67f

Browse files
committed
Merge remote-tracking branch 'giteaofficial/main'
* giteaofficial/main: Fix and clean up `ConfirmModal` (go-gitea#31283) Enable poetry non-package mode (go-gitea#31282) fixed the dropdown menu for the top New button to expand to the left (go-gitea#31273) Optimize repo-list layout to enhance visual experience (go-gitea#31272) Allow including `Reviewed-on`/`Reviewed-by` lines for custom merge messages (go-gitea#31211) Add `MAX_ROWS` option for CSV rendering (go-gitea#30268) Update `golang.org/x/net` (go-gitea#31260) Add replacement module for `mholt/archiver` (go-gitea#31267) Fix Activity Page Contributors dropdown (go-gitea#31264)
2 parents bb1a8ac + 291a00d commit 77ff67f

File tree

23 files changed

+137
-150
lines changed

23 files changed

+137
-150
lines changed

Diff for: Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -878,7 +878,7 @@ node_modules: package-lock.json
878878
@touch node_modules
879879

880880
.venv: poetry.lock
881-
poetry install --no-root
881+
poetry install
882882
@touch .venv
883883

884884
.PHONY: update
@@ -895,7 +895,7 @@ update-js: node-check | node_modules
895895
update-py: node-check | node_modules
896896
npx updates -u -f pyproject.toml
897897
rm -rf .venv poetry.lock
898-
poetry install --no-root
898+
poetry install
899899
@touch .venv
900900

901901
.PHONY: fomantic

Diff for: custom/conf/app.example.ini

+3
Original file line numberDiff line numberDiff line change
@@ -1334,6 +1334,9 @@ LEVEL = Info
13341334
;;
13351335
;; Maximum allowed file size in bytes to render CSV files as table. (Set to 0 for no limit).
13361336
;MAX_FILE_SIZE = 524288
1337+
;;
1338+
;; Maximum allowed rows to render CSV files. (Set to 0 for no limit)
1339+
;MAX_ROWS = 2500
13371340

13381341
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
13391342
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Diff for: docs/content/usage/merge-message-templates.en-us.md

+2
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ You can use the following variables enclosed in `${}` inside these templates whi
4444
- PullRequestIndex: Pull request's index number
4545
- PullRequestReference: Pull request's reference char with index number. i.e. #1, !2
4646
- ClosingIssues: return a string contains all issues which will be closed by this pull request i.e. `close #1, close #2`
47+
- ReviewedOn: Which pull request this commit belongs to. For example `Reviewed-on: https://gitea.com/foo/bar/pulls/1`
48+
- ReviewedBy: Who approved the pull request before the merge. For example `Reviewed-by: Jane Doe <[email protected]>`
4749

4850
## Rebase
4951

Diff for: go.mod

+10-7
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,13 @@ require (
108108
github.com/yuin/goldmark v1.7.0
109109
github.com/yuin/goldmark-highlighting/v2 v2.0.0-20230729083705-37449abec8cc
110110
github.com/yuin/goldmark-meta v1.1.0
111-
golang.org/x/crypto v0.22.0
111+
golang.org/x/crypto v0.24.0
112112
golang.org/x/image v0.15.0
113-
golang.org/x/net v0.24.0
113+
golang.org/x/net v0.26.0
114114
golang.org/x/oauth2 v0.18.0
115-
golang.org/x/sys v0.19.0
116-
golang.org/x/text v0.14.0
117-
golang.org/x/tools v0.19.0
115+
golang.org/x/sys v0.21.0
116+
golang.org/x/text v0.16.0
117+
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d
118118
google.golang.org/grpc v1.62.1
119119
google.golang.org/protobuf v1.33.0
120120
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df
@@ -293,8 +293,8 @@ require (
293293
go.uber.org/multierr v1.11.0 // indirect
294294
go.uber.org/zap v1.27.0 // indirect
295295
golang.org/x/exp v0.0.0-20240314144324-c7f7c6466f7f // indirect
296-
golang.org/x/mod v0.16.0 // indirect
297-
golang.org/x/sync v0.6.0 // indirect
296+
golang.org/x/mod v0.17.0 // indirect
297+
golang.org/x/sync v0.7.0 // indirect
298298
golang.org/x/time v0.5.0 // indirect
299299
google.golang.org/appengine v1.6.8 // indirect
300300
google.golang.org/genproto/googleapis/rpc v0.0.0-20240314234333-6e1732d8331c // indirect
@@ -311,6 +311,9 @@ replace github.com/nektos/act => gitea.com/gitea/act v0.259.1
311311

312312
replace github.com/gorilla/feeds => github.com/yardenshoham/feeds v0.0.0-20240110072658-f3d0c21c0bd5
313313

314+
// TODO: This could be removed after https://github.com/mholt/archiver/pull/396 merged
315+
replace github.com/mholt/archiver/v3 => github.com/anchore/archiver/v3 v3.5.2
316+
314317
exclude github.com/gofrs/uuid v3.2.0+incompatible
315318

316319
exclude github.com/gofrs/uuid v4.0.0+incompatible

Diff for: go.sum

+18-17
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ github.com/alecthomas/repr v0.4.0 h1:GhI2A8MACjfegCPVq9f1FLvIBS+DrQ2KQBFZP1iFzXc
9292
github.com/alecthomas/repr v0.4.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4=
9393
github.com/alexbrainman/sspi v0.0.0-20210105120005-909beea2cc74 h1:Kk6a4nehpJ3UuJRqlA3JxYxBZEqCeOmATOvrbT4p9RA=
9494
github.com/alexbrainman/sspi v0.0.0-20210105120005-909beea2cc74/go.mod h1:cEWa1LVoE5KvSD9ONXsZrj0z6KqySlCCNKHlLzbqAt4=
95+
github.com/anchore/archiver/v3 v3.5.2 h1:Bjemm2NzuRhmHy3m0lRe5tNoClB9A4zYyDV58PaB6aA=
96+
github.com/anchore/archiver/v3 v3.5.2/go.mod h1:e3dqJ7H78uzsRSEACH1joayhuSyhnonssnDhppzS1L4=
9597
github.com/andybalholm/brotli v1.0.1/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu3qAvBg8x/Y=
9698
github.com/andybalholm/brotli v1.0.4/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig=
9799
github.com/andybalholm/brotli v1.1.0 h1:eLKJA0d02Lf0mVpIDgYnqXcUn0GqVmEFny3VuID1U3M=
@@ -564,8 +566,6 @@ github.com/meilisearch/meilisearch-go v0.26.2 h1:3gTlmiV1dHHumVUhYdJbvh3camiNiyq
564566
github.com/meilisearch/meilisearch-go v0.26.2/go.mod h1:SxuSqDcPBIykjWz1PX+KzsYzArNLSCadQodWs8extS0=
565567
github.com/mholt/acmez v1.2.0 h1:1hhLxSgY5FvH5HCnGUuwbKY2VQVo8IU7rxXKSnZ7F30=
566568
github.com/mholt/acmez v1.2.0/go.mod h1:VT9YwH1xgNX1kmYY89gY8xPJC84BFAisjo8Egigt4kE=
567-
github.com/mholt/archiver/v3 v3.5.1 h1:rDjOBX9JSF5BvoJGvjqK479aL70qh9DIpZCl+k7Clwo=
568-
github.com/mholt/archiver/v3 v3.5.1/go.mod h1:e3dqJ7H78uzsRSEACH1joayhuSyhnonssnDhppzS1L4=
569569
github.com/microcosm-cc/bluemonday v1.0.26 h1:xbqSvqzQMeEHCqMi64VAs4d8uy6Mequs3rQ0k/Khz58=
570570
github.com/microcosm-cc/bluemonday v1.0.26/go.mod h1:JyzOCs9gkyQyjs+6h10UEVSe02CGwkhd72Xdqh78TWs=
571571
github.com/microsoft/go-mssqldb v1.7.0 h1:sgMPW0HA6Ihd37Yx0MzHyKD726C2kY/8KJsQtXHNaAs=
@@ -866,8 +866,8 @@ golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2Uz
866866
golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU=
867867
golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc=
868868
golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=
869-
golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30=
870-
golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M=
869+
golang.org/x/crypto v0.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI=
870+
golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM=
871871
golang.org/x/exp v0.0.0-20240314144324-c7f7c6466f7f h1:3CW0unweImhOzd5FmYuRsD4Y4oQFKZIjAnKbjV4WIrw=
872872
golang.org/x/exp v0.0.0-20240314144324-c7f7c6466f7f/go.mod h1:CxmFvTBINI24O/j8iY7H1xHzx2i4OsyguNBmN/uPtqc=
873873
golang.org/x/image v0.15.0 h1:kOELfmgrmJlw4Cdb7g/QGuB3CvDrXbqEIww/pNtNBm8=
@@ -878,8 +878,8 @@ golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
878878
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
879879
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
880880
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
881-
golang.org/x/mod v0.16.0 h1:QX4fJ0Rr5cPQCF7O9lh9Se4pmwfwskqZfq5moyldzic=
882-
golang.org/x/mod v0.16.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
881+
golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA=
882+
golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
883883
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
884884
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
885885
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
@@ -900,8 +900,8 @@ golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
900900
golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc=
901901
golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns=
902902
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
903-
golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w=
904-
golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8=
903+
golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ=
904+
golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE=
905905
golang.org/x/oauth2 v0.18.0 h1:09qnuIAgzdx1XplqJvW6CQqMCtGZykZWcXzPMPUusvI=
906906
golang.org/x/oauth2 v0.18.0/go.mod h1:Wf7knwG0MPoWIMMBgFlEaSUDaKskp0dCfrlJRJXbBi8=
907907
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@@ -912,8 +912,8 @@ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJ
912912
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
913913
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
914914
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
915-
golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ=
916-
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
915+
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
916+
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
917917
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
918918
golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
919919
golang.org/x/sys v0.0.0-20181221143128-b4a75ba826a6/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
@@ -951,8 +951,8 @@ golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
951951
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
952952
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
953953
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
954-
golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o=
955-
golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
954+
golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws=
955+
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
956956
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
957957
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
958958
golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc=
@@ -962,8 +962,8 @@ golang.org/x/term v0.7.0/go.mod h1:P32HKFT3hSsZrRxla30E9HqToFYAQPCMs/zFMBUFqPY=
962962
golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
963963
golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU=
964964
golang.org/x/term v0.15.0/go.mod h1:BDl952bC7+uMoWR75FIrCDx79TPU9oHkTZ9yRbYOrX0=
965-
golang.org/x/term v0.19.0 h1:+ThwsDv+tYfnJFhF4L8jITxu1tdTWRTZpdsWgEgjL6Q=
966-
golang.org/x/term v0.19.0/go.mod h1:2CuTdWZ7KHSQwUzKva0cbMg6q2DMI3Mmxp+gKJbskEk=
965+
golang.org/x/term v0.21.0 h1:WVXCp+/EBEHOj53Rvu+7KiT/iElMrO8ACK16SMZ3jaA=
966+
golang.org/x/term v0.21.0/go.mod h1:ooXLefLobQVslOqselCNF4SxFAaoS6KujMbsGzSDmX0=
967967
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
968968
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
969969
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
@@ -975,8 +975,9 @@ golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
975975
golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
976976
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
977977
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
978-
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
979978
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
979+
golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
980+
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
980981
golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk=
981982
golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
982983
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
@@ -991,8 +992,8 @@ golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4f
991992
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
992993
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
993994
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
994-
golang.org/x/tools v0.19.0 h1:tfGCXNR1OsFG+sVdLAitlpjAvD/I6dHDKnYrpEZUHkw=
995-
golang.org/x/tools v0.19.0/go.mod h1:qoJWxmGSIBmAeriMx19ogtrEPrGtDbPK634QFIcLAhc=
995+
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg=
996+
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
996997
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
997998
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
998999
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=

Diff for: modules/markup/csv/csv.go

+35-59
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ package markup
55

66
import (
77
"bufio"
8-
"bytes"
9-
"fmt"
108
"html"
119
"io"
1210
"regexp"
@@ -15,6 +13,8 @@ import (
1513
"code.gitea.io/gitea/modules/csv"
1614
"code.gitea.io/gitea/modules/markup"
1715
"code.gitea.io/gitea/modules/setting"
16+
"code.gitea.io/gitea/modules/translation"
17+
"code.gitea.io/gitea/modules/util"
1818
)
1919

2020
func init() {
@@ -81,86 +81,38 @@ func writeField(w io.Writer, element, class, field string) error {
8181
func (r Renderer) Render(ctx *markup.RenderContext, input io.Reader, output io.Writer) error {
8282
tmpBlock := bufio.NewWriter(output)
8383
maxSize := setting.UI.CSV.MaxFileSize
84+
maxRows := setting.UI.CSV.MaxRows
8485

85-
if maxSize == 0 {
86-
return r.tableRender(ctx, input, tmpBlock)
86+
if maxSize != 0 {
87+
input = io.LimitReader(input, maxSize+1)
8788
}
8889

89-
rawBytes, err := io.ReadAll(io.LimitReader(input, maxSize+1))
90-
if err != nil {
91-
return err
92-
}
93-
94-
if int64(len(rawBytes)) <= maxSize {
95-
return r.tableRender(ctx, bytes.NewReader(rawBytes), tmpBlock)
96-
}
97-
return r.fallbackRender(io.MultiReader(bytes.NewReader(rawBytes), input), tmpBlock)
98-
}
99-
100-
func (Renderer) fallbackRender(input io.Reader, tmpBlock *bufio.Writer) error {
101-
_, err := tmpBlock.WriteString("<pre>")
102-
if err != nil {
103-
return err
104-
}
105-
106-
scan := bufio.NewScanner(input)
107-
scan.Split(bufio.ScanRunes)
108-
for scan.Scan() {
109-
switch scan.Text() {
110-
case `&`:
111-
_, err = tmpBlock.WriteString("&amp;")
112-
case `'`:
113-
_, err = tmpBlock.WriteString("&#39;") // "&#39;" is shorter than "&apos;" and apos was not in HTML until HTML5.
114-
case `<`:
115-
_, err = tmpBlock.WriteString("&lt;")
116-
case `>`:
117-
_, err = tmpBlock.WriteString("&gt;")
118-
case `"`:
119-
_, err = tmpBlock.WriteString("&#34;") // "&#34;" is shorter than "&quot;".
120-
default:
121-
_, err = tmpBlock.Write(scan.Bytes())
122-
}
123-
if err != nil {
124-
return err
125-
}
126-
}
127-
if err = scan.Err(); err != nil {
128-
return fmt.Errorf("fallbackRender scan: %w", err)
129-
}
130-
131-
_, err = tmpBlock.WriteString("</pre>")
132-
if err != nil {
133-
return err
134-
}
135-
return tmpBlock.Flush()
136-
}
137-
138-
func (Renderer) tableRender(ctx *markup.RenderContext, input io.Reader, tmpBlock *bufio.Writer) error {
13990
rd, err := csv.CreateReaderAndDetermineDelimiter(ctx, input)
14091
if err != nil {
14192
return err
14293
}
143-
14494
if _, err := tmpBlock.WriteString(`<table class="data-table">`); err != nil {
14595
return err
14696
}
147-
row := 1
97+
98+
row := 0
14899
for {
149100
fields, err := rd.Read()
150-
if err == io.EOF {
101+
if err == io.EOF || (row >= maxRows && maxRows != 0) {
151102
break
152103
}
153104
if err != nil {
154105
continue
155106
}
107+
156108
if _, err := tmpBlock.WriteString("<tr>"); err != nil {
157109
return err
158110
}
159111
element := "td"
160-
if row == 1 {
112+
if row == 0 {
161113
element = "th"
162114
}
163-
if err := writeField(tmpBlock, element, "line-num", strconv.Itoa(row)); err != nil {
115+
if err := writeField(tmpBlock, element, "line-num", strconv.Itoa(row+1)); err != nil {
164116
return err
165117
}
166118
for _, field := range fields {
@@ -174,8 +126,32 @@ func (Renderer) tableRender(ctx *markup.RenderContext, input io.Reader, tmpBlock
174126

175127
row++
176128
}
129+
177130
if _, err = tmpBlock.WriteString("</table>"); err != nil {
178131
return err
179132
}
133+
134+
// Check if maxRows or maxSize is reached, and if true, warn.
135+
if (row >= maxRows && maxRows != 0) || (rd.InputOffset() >= maxSize && maxSize != 0) {
136+
warn := `<table class="data-table"><tr><td>`
137+
rawLink := ` <a href="` + ctx.Links.RawLink() + `/` + util.PathEscapeSegments(ctx.RelativePath) + `">`
138+
139+
// Try to get the user translation
140+
if locale, ok := ctx.Ctx.Value(translation.ContextKey).(translation.Locale); ok {
141+
warn += locale.TrString("repo.file_too_large")
142+
rawLink += locale.TrString("repo.file_view_raw")
143+
} else {
144+
warn += "The file is too large to be shown."
145+
rawLink += "View Raw"
146+
}
147+
148+
warn += rawLink + `</a></td></tr></table>`
149+
150+
// Write the HTML string to the output
151+
if _, err := tmpBlock.WriteString(warn); err != nil {
152+
return err
153+
}
154+
}
155+
180156
return tmpBlock.Flush()
181157
}

Diff for: modules/markup/csv/csv_test.go

-10
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
package markup
55

66
import (
7-
"bufio"
8-
"bytes"
97
"strings"
108
"testing"
119

@@ -31,12 +29,4 @@ func TestRenderCSV(t *testing.T) {
3129
assert.NoError(t, err)
3230
assert.EqualValues(t, v, buf.String())
3331
}
34-
35-
t.Run("fallbackRender", func(t *testing.T) {
36-
var buf bytes.Buffer
37-
err := render.fallbackRender(strings.NewReader("1,<a>\n2,<b>"), bufio.NewWriter(&buf))
38-
assert.NoError(t, err)
39-
want := "<pre>1,&lt;a&gt;\n2,&lt;b&gt;</pre>"
40-
assert.Equal(t, want, buf.String())
41-
})
4232
}

Diff for: modules/setting/ui.go

+3
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ var UI = struct {
5252

5353
CSV struct {
5454
MaxFileSize int64
55+
MaxRows int
5556
} `ini:"ui.csv"`
5657

5758
Admin struct {
@@ -107,8 +108,10 @@ var UI = struct {
107108
},
108109
CSV: struct {
109110
MaxFileSize int64
111+
MaxRows int
110112
}{
111113
MaxFileSize: 524288,
114+
MaxRows: 2500,
112115
},
113116
Admin: struct {
114117
UserPagingNum int

Diff for: pyproject.toml

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
[tool.poetry]
2-
name = "gitea"
3-
version = "0.0.0"
4-
description = ""
5-
authors = []
2+
package-mode = false
63

74
[tool.poetry.dependencies]
85
python = "^3.10"

Diff for: routers/web/repo/contributors.go

-6
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,8 @@ const (
1919
// Contributors render the page to show repository contributors graph
2020
func Contributors(ctx *context.Context) {
2121
ctx.Data["Title"] = ctx.Tr("repo.activity.navbar.contributors")
22-
2322
ctx.Data["PageIsActivity"] = true
2423
ctx.Data["PageIsContributors"] = true
25-
26-
ctx.PageData["contributionType"] = "commits"
27-
28-
ctx.PageData["repoLink"] = ctx.Repo.RepoLink
29-
3024
ctx.HTML(http.StatusOK, tplContributors)
3125
}
3226

0 commit comments

Comments
 (0)