Skip to content

Commit e51abe1

Browse files
authored
Merge branch 'main' into fix-15844-move-sans-serif-up
2 parents 48a2f98 + b6b8b19 commit e51abe1

Some content is hidden

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

85 files changed

+2700
-1236
lines changed

.drone.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ trigger:
1515
steps:
1616
- name: deps-frontend
1717
pull: always
18-
image: node:14
18+
image: node:16
1919
commands:
2020
- make node_modules
2121

2222
- name: lint-frontend
23-
image: node:14
23+
image: node:16
2424
commands:
2525
- make lint-frontend
2626
depends_on: [deps-frontend]
@@ -58,7 +58,7 @@ steps:
5858
TAGS: bindata gogit sqlite sqlite_unlock_notify
5959

6060
- name: checks-frontend
61-
image: node:14
61+
image: node:16
6262
commands:
6363
- make checks-frontend
6464
depends_on: [deps-frontend]
@@ -71,13 +71,13 @@ steps:
7171
depends_on: [lint-backend]
7272

7373
- name: test-frontend
74-
image: node:14
74+
image: node:16
7575
commands:
7676
- make test-frontend
7777
depends_on: [lint-frontend]
7878

7979
- name: build-frontend
80-
image: node:14
80+
image: node:16
8181
commands:
8282
- make frontend
8383
depends_on: [test-frontend]

.eslintrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,7 @@ rules:
366366
unicorn/no-array-instanceof: [0]
367367
unicorn/no-array-push-push: [2]
368368
unicorn/no-console-spaces: [0]
369+
unicorn/no-document-cookie: [2]
369370
unicorn/no-fn-reference-in-iterator: [0]
370371
unicorn/no-for-loop: [0]
371372
unicorn/no-hex-escape: [0]
@@ -389,6 +390,7 @@ rules:
389390
unicorn/numeric-separators-style: [0]
390391
unicorn/prefer-add-event-listener: [2]
391392
unicorn/prefer-array-find: [2]
393+
unicorn/prefer-array-flat-map: [2]
392394
unicorn/prefer-array-flat: [2]
393395
unicorn/prefer-array-index-of: [2]
394396
unicorn/prefer-array-some: [2]
@@ -399,8 +401,10 @@ rules:
399401
unicorn/prefer-includes: [2]
400402
unicorn/prefer-math-trunc: [2]
401403
unicorn/prefer-modern-dom-apis: [0]
404+
unicorn/prefer-module: [2]
402405
unicorn/prefer-negative-index: [2]
403406
unicorn/prefer-node-append: [0]
407+
unicorn/prefer-node-protocol: [0]
404408
unicorn/prefer-node-remove: [0]
405409
unicorn/prefer-number-properties: [0]
406410
unicorn/prefer-optional-catch-binding: [2]

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ cpu.out
7676
/integrations/mssql.ini
7777
/node_modules
7878
/yarn.lock
79+
/yarn-error.log
80+
/npm-debug.log*
7981
/public/js
8082
/public/serviceworker.js
8183
/public/css

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ test-backend:
359359
@$(GO) test $(GOTESTFLAGS) -mod=vendor -tags='$(TEST_TAGS)' $(GO_PACKAGES)
360360

361361
.PHONY: test-frontend
362-
test-frontend:
362+
test-frontend: node_modules
363363
@NODE_OPTIONS="--experimental-vm-modules --no-warnings" npx jest --color
364364

365365
.PHONY: test-check

cmd/web_letsencrypt.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,14 @@ func runLetsEncrypt(listenAddr, domain, directory, email string, m http.Handler)
2424
enableHTTPChallenge := true
2525
enableTLSALPNChallenge := true
2626
altHTTPPort := 0
27+
altTLSALPNPort := 0
2728

2829
if p, err := strconv.Atoi(setting.PortToRedirect); err == nil {
2930
altHTTPPort = p
3031
}
32+
if p, err := strconv.Atoi(setting.HTTPPort); err == nil {
33+
altTLSALPNPort = p
34+
}
3135

3236
magic := certmagic.NewDefault()
3337
magic.Storage = &certmagic.FileStorage{Path: directory}
@@ -36,7 +40,8 @@ func runLetsEncrypt(listenAddr, domain, directory, email string, m http.Handler)
3640
Agreed: setting.LetsEncryptTOS,
3741
DisableHTTPChallenge: !enableHTTPChallenge,
3842
DisableTLSALPNChallenge: !enableTLSALPNChallenge,
39-
ListenHost: listenAddr,
43+
ListenHost: setting.HTTPAddr,
44+
AltTLSALPNPort: altTLSALPNPort,
4045
AltHTTPPort: altHTTPPort,
4146
})
4247

contrib/environment-to-ini/environment-to-ini.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ func runEnvironmentToIni(c *cli.Context) error {
110110
}
111111
cfg.NameMapper = ini.SnackCase
112112

113+
changed := false
114+
113115
prefix := c.String("prefix") + "__"
114116

115117
for _, kv := range os.Environ() {
@@ -143,15 +145,21 @@ func runEnvironmentToIni(c *cli.Context) error {
143145
continue
144146
}
145147
}
148+
oldValue := key.Value()
149+
if !changed && oldValue != value {
150+
changed = true
151+
}
146152
key.SetValue(value)
147153
}
148154
destination := c.String("out")
149155
if len(destination) == 0 {
150156
destination = setting.CustomConf
151157
}
152-
err = cfg.SaveTo(destination)
153-
if err != nil {
154-
return err
158+
if destination != setting.CustomConf || changed {
159+
err = cfg.SaveTo(destination)
160+
if err != nil {
161+
return err
162+
}
155163
}
156164
if c.Bool("clear") {
157165
for _, kv := range os.Environ() {

docs/content/doc/advanced/logging-documentation.en-us.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,8 @@ Gitea includes built-in log rotation, which should be enough for most deployment
437437

438438
- Disable built-in log rotation by setting `LOG_ROTATE` to `false` in your `app.ini`.
439439
- Install `logrotate`.
440-
- Configure `logrotate` to match your deployment requirements, see `man 8 logrotate` for configuration syntax details. In the `postrotate/endscript` block send Gitea a `USR1` signal via `kill -USR1` or `kill -10`, or run `gitea manager logging release-and-reopen` (with the appropriate environment). Ensure that your configurations apply to all files emitted by Gitea loggers as described in the above sections.
441-
- Always do `logrotate /etc/logrotate.conf --debug` to test your configurations.
440+
- Configure `logrotate` to match your deployment requirements, see `man 8 logrotate` for configuration syntax details. In the `postrotate/endscript` block send Gitea a `USR1` signal via `kill -USR1` or `kill -10` to the `gitea` process itself, or run `gitea manager logging release-and-reopen` (with the appropriate environment). Ensure that your configurations apply to all files emitted by Gitea loggers as described in the above sections.
441+
- Always do `logrotate /etc/logrotate.conf --debug` to test your configurations.
442+
- If you are using docker and are running from outside of the container you can use `docker exec -u $OS_USER $CONTAINER_NAME sh -c 'gitea manager logging release-and-reopen'` or `docker exec $CONTAINER_NAME sh -c '/bin/s6-svc -1 /etc/s6/gitea/'` or send `USR1` directly to the gitea process itself.
442443

443444
The next `logrotate` jobs will include your configurations, so no restart is needed. You can also immediately reload `logrotate` with `logrotate /etc/logrotate.conf --force`.

docs/content/doc/usage/reverse-proxies.en-us.md

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,11 +222,24 @@ If you wish to run Gitea with IIS. You will need to setup IIS with URL Rewrite a
222222
<?xml version="1.0" encoding="UTF-8"?>
223223
<configuration>
224224
<system.webServer>
225+
<security>
226+
<requestFiltering>
227+
<hiddenSegments>
228+
<clear />
229+
</hiddenSegments>
230+
<denyUrlSequences>
231+
<clear />
232+
</denyUrlSequences>
233+
<fileExtensions allowUnlisted="true">
234+
<clear />
235+
</fileExtensions>
236+
</requestFiltering>
237+
</security>
225238
<rewrite>
226-
<rules>
239+
<rules useOriginalURLEncoding="false">
227240
<rule name="ReverseProxyInboundRule1" stopProcessing="true">
228241
<match url="(.*)" />
229-
<action type="Rewrite" url="http://127.0.0.1:3000/{R:1}" />
242+
<action type="Rewrite" url="http://127.0.0.1:3000{UNENCODED_URL}" />
230243
<serverVariables>
231244
<set name="HTTP_X_ORIGINAL_ACCEPT_ENCODING" value="HTTP_ACCEPT_ENCODING" />
232245
<set name="HTTP_ACCEPT_ENCODING" value="" />
@@ -255,6 +268,16 @@ If you wish to run Gitea with IIS. You will need to setup IIS with URL Rewrite a
255268
</outboundRules>
256269
</rewrite>
257270
<urlCompression doDynamicCompression="true" />
271+
<handlers>
272+
<clear />
273+
<add name="StaticFile" path="*" verb="*" modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule" resourceType="Either" requireAccess="Read" />
274+
</handlers>
275+
<!-- Map all extensions to the same MIME type, so all files can be
276+
downloaded. -->
277+
<staticContent>
278+
<clear />
279+
<mimeMap fileExtension="*" mimeType="application/octet-stream" />
280+
</staticContent>
258281
</system.webServer>
259282
</configuration>
260283
```

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ require (
131131
mvdan.cc/xurls/v2 v2.2.0
132132
strk.kbt.io/projects/go/libravatar v0.0.0-20191008002943-06d1c002b251
133133
xorm.io/builder v0.3.9
134-
xorm.io/xorm v1.0.7
134+
xorm.io/xorm v1.1.0
135135
)
136136

137137
replace github.com/hashicorp/go-version => github.com/6543/go-version v1.3.1

go.sum

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
250250
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
251251
github.com/denisenkom/go-mssqldb v0.0.0-20191128021309-1d7a30a10f73/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU=
252252
github.com/denisenkom/go-mssqldb v0.0.0-20200428022330-06a60b6afbbc/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU=
253+
github.com/denisenkom/go-mssqldb v0.9.0/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU=
253254
github.com/denisenkom/go-mssqldb v0.10.0 h1:QykgLZBorFE95+gO3u9esLd0BmbvpWp0/waNNZfHBM8=
254255
github.com/denisenkom/go-mssqldb v0.10.0/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU=
255256
github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM=
@@ -812,6 +813,7 @@ github.com/mattn/go-runewidth v0.0.12 h1:Y41i/hVW3Pgwr8gV+J23B9YEY0zxjptBuCWEaxm
812813
github.com/mattn/go-runewidth v0.0.12/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk=
813814
github.com/mattn/go-sqlite3 v1.11.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
814815
github.com/mattn/go-sqlite3 v1.14.0/go.mod h1:JIl7NbARA7phWnGvh0LKTyg7S9BA+6gx71ShQilpsus=
816+
github.com/mattn/go-sqlite3 v1.14.6/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
815817
github.com/mattn/go-sqlite3 v1.14.7 h1:fxWBnXkxfM6sRiuH3bqJ4CfzZojMOLVc0UTsTglEghA=
816818
github.com/mattn/go-sqlite3 v1.14.7/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
817819
github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU=
@@ -982,6 +984,8 @@ github.com/quasoft/websspi v1.0.0 h1:5nDgdM5xSur9s+B5w2xQ5kxf5nUGqgFgU4W0aDLZ8Mw
982984
github.com/quasoft/websspi v1.0.0/go.mod h1:HmVdl939dQ0WIXZhyik+ARdI03M6bQzaSEKcgpFmewk=
983985
github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
984986
github.com/rcrowley/go-metrics v0.0.0-20190826022208-cac0b30c2563/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
987+
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 h1:OdAsTTz6OkFY5QxjkYwrChwuRruF69c169dPK26NUlk=
988+
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
985989
github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
986990
github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
987991
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
@@ -1403,6 +1407,7 @@ golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7w
14031407
golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
14041408
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
14051409
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
1410+
golang.org/x/sys v0.0.0-20201126233918-771906719818/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
14061411
golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
14071412
golang.org/x/sys v0.0.0-20210104204734-6f8348627aad/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
14081413
golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@@ -1496,6 +1501,7 @@ golang.org/x/tools v0.0.0-20200904185747-39188db58858/go.mod h1:Cj7w3i3Rnn0Xh82u
14961501
golang.org/x/tools v0.0.0-20200928182047-19e03678916f/go.mod h1:z6u4i615ZeAfBE4XtMziQW1fSVJXACjjbWkB/mvPzlU=
14971502
golang.org/x/tools v0.0.0-20200929161345-d7fc70abf50f/go.mod h1:z6u4i615ZeAfBE4XtMziQW1fSVJXACjjbWkB/mvPzlU=
14981503
golang.org/x/tools v0.0.0-20201110124207-079ba7bd75cd/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
1504+
golang.org/x/tools v0.0.0-20201124115921-2c860bdd6e78/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
14991505
golang.org/x/tools v0.0.0-20201201161351-ac6f37ff4c2a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
15001506
golang.org/x/tools v0.0.0-20201208233053-a543418bbed2/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
15011507
golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
@@ -1663,6 +1669,33 @@ honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt
16631669
honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
16641670
honnef.co/go/tools v0.0.1-2020.1.4 h1:UoveltGrhghAA7ePc+e+QYDHXrBps2PqFZiHkGR/xK8=
16651671
honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
1672+
modernc.org/cc/v3 v3.31.5-0.20210308123301-7a3e9dab9009 h1:u0oCo5b9wyLr++HF3AN9JicGhkUxJhMz51+8TIZH9N0=
1673+
modernc.org/cc/v3 v3.31.5-0.20210308123301-7a3e9dab9009/go.mod h1:0R6jl1aZlIl2avnYfbfHBS1QB6/f+16mihBObaBC878=
1674+
modernc.org/ccgo/v3 v3.9.0 h1:JbcEIqjw4Agf+0g3Tc85YvfYqkkFOv6xBwS4zkfqSoA=
1675+
modernc.org/ccgo/v3 v3.9.0/go.mod h1:nQbgkn8mwzPdp4mm6BT6+p85ugQ7FrGgIcYaE7nSrpY=
1676+
modernc.org/httpfs v1.0.6 h1:AAgIpFZRXuYnkjftxTAZwMIiwEqAfk8aVB2/oA6nAeM=
1677+
modernc.org/httpfs v1.0.6/go.mod h1:7dosgurJGp0sPaRanU53W4xZYKh14wfzX420oZADeHM=
1678+
modernc.org/libc v1.7.13-0.20210308123627-12f642a52bb8/go.mod h1:U1eq8YWr/Kc1RWCMFUWEdkTg8OTcfLw2kY8EDwl039w=
1679+
modernc.org/libc v1.8.0 h1:Pp4uv9g0csgBMpGPABKtkieF6O5MGhfGo6ZiOdlYfR8=
1680+
modernc.org/libc v1.8.0/go.mod h1:U1eq8YWr/Kc1RWCMFUWEdkTg8OTcfLw2kY8EDwl039w=
1681+
modernc.org/mathutil v1.1.1/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E=
1682+
modernc.org/mathutil v1.2.2 h1:+yFk8hBprV+4c0U9GjFtL+dV3N8hOJ8JCituQcMShFY=
1683+
modernc.org/mathutil v1.2.2/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E=
1684+
modernc.org/memory v1.0.4 h1:utMBrFcpnQDdNsmM6asmyH/FM9TqLPS7XF7otpJmrwM=
1685+
modernc.org/memory v1.0.4/go.mod h1:nV2OApxradM3/OVbs2/0OsP6nPfakXpi50C7dcoHXlc=
1686+
modernc.org/opt v0.1.1 h1:/0RX92k9vwVeDXj+Xn23DKp2VJubL7k8qNffND6qn3A=
1687+
modernc.org/opt v0.1.1/go.mod h1:WdSiB5evDcignE70guQKxYUl14mgWtbClRi5wmkkTX0=
1688+
modernc.org/sqlite v1.10.1-0.20210314190707-798bbeb9bb84 h1:rgEUzE849tFlHSoeCrKyS9cZAljC+DY7MdMHKq6R6sY=
1689+
modernc.org/sqlite v1.10.1-0.20210314190707-798bbeb9bb84/go.mod h1:PGzq6qlhyYjL6uVbSgS6WoF7ZopTW/sI7+7p+mb4ZVU=
1690+
modernc.org/strutil v1.1.0 h1:+1/yCzZxY2pZwwrsbH+4T7BQMoLQ9QiBshRC9eicYsc=
1691+
modernc.org/strutil v1.1.0/go.mod h1:lstksw84oURvj9y3tn8lGvRxyRC1S2+g5uuIzNfIOBs=
1692+
modernc.org/tcl v1.5.0 h1:euZSUNfE0Fd4W8VqXI1Ly1v7fqDJoBuAV88Ea+SnaSs=
1693+
modernc.org/tcl v1.5.0/go.mod h1:gb57hj4pO8fRrK54zveIfFXBaMHK3SKJNWcmRw1cRzc=
1694+
modernc.org/token v1.0.0 h1:a0jaWiNMDhDUtqOj09wvjWWAqd3q7WpBulmL9H2egsk=
1695+
modernc.org/token v1.0.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM=
1696+
modernc.org/z v1.0.1-0.20210308123920-1f282aa71362/go.mod h1:8/SRk5C/HgiQWCgXdfpb+1RvhORdkz5sw72d3jjtyqA=
1697+
modernc.org/z v1.0.1 h1:WyIDpEpAIx4Hel6q/Pcgj/VhaQV5XPJ2I6ryIYbjnpc=
1698+
modernc.org/z v1.0.1/go.mod h1:8/SRk5C/HgiQWCgXdfpb+1RvhORdkz5sw72d3jjtyqA=
16661699
mvdan.cc/xurls/v2 v2.2.0 h1:NSZPykBXJFCetGZykLAxaL6SIpvbVy/UFEniIfHAa8A=
16671700
mvdan.cc/xurls/v2 v2.2.0/go.mod h1:EV1RMtya9D6G5DMYPGD8zTQzaHet6Jh8gFlRgGRJeO8=
16681701
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
@@ -1673,8 +1706,9 @@ sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0/go.mod h1
16731706
strk.kbt.io/projects/go/libravatar v0.0.0-20191008002943-06d1c002b251 h1:mUcz5b3FJbP5Cvdq7Khzn6J9OCUQJaBwgBkCR+MOwSs=
16741707
strk.kbt.io/projects/go/libravatar v0.0.0-20191008002943-06d1c002b251/go.mod h1:FJGmPh3vz9jSos1L/F91iAgnC/aejc0wIIrF2ZwJxdY=
16751708
xorm.io/builder v0.3.7/go.mod h1:aUW0S9eb9VCaPohFCH3j7czOx1PMW3i1HrSzbLYGBSE=
1709+
xorm.io/builder v0.3.8/go.mod h1:aUW0S9eb9VCaPohFCH3j7czOx1PMW3i1HrSzbLYGBSE=
16761710
xorm.io/builder v0.3.9 h1:Sd65/LdWyO7LR8+Cbd+e7mm3sK/7U9k0jS3999IDHMc=
16771711
xorm.io/builder v0.3.9/go.mod h1:aUW0S9eb9VCaPohFCH3j7czOx1PMW3i1HrSzbLYGBSE=
16781712
xorm.io/xorm v1.0.6/go.mod h1:uF9EtbhODq5kNWxMbnBEj8hRRZnlcNSz2t2N7HW/+A4=
1679-
xorm.io/xorm v1.0.7 h1:26yBTDVI+CfQpVz2Y88fISh+aiJXIPP4eNoTJlwzsC4=
1680-
xorm.io/xorm v1.0.7/go.mod h1:uF9EtbhODq5kNWxMbnBEj8hRRZnlcNSz2t2N7HW/+A4=
1713+
xorm.io/xorm v1.1.0 h1:mkEsQXLauZajiOld2cB2PkFcUZKePepPgs1bC1dw8RA=
1714+
xorm.io/xorm v1.1.0/go.mod h1:EDzNHMuCVZNszkIRSLL2nI0zX+nQE8RstAVranlSfqI=

jest.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
export default {
22
setupFilesAfterEnv: ['jest-extended'],
33
testTimeout: 20000,
4+
rootDir: 'web_src',
45
testMatch: [
5-
'**/web_src/**/*.test.js',
6+
'<rootDir>/**/*.test.js',
67
],
78
transform: {},
89
verbose: false,

models/login_source.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"code.gitea.io/gitea/modules/setting"
2222
"code.gitea.io/gitea/modules/timeutil"
2323
"code.gitea.io/gitea/modules/util"
24+
gouuid "github.com/google/uuid"
2425
jsoniter "github.com/json-iterator/go"
2526

2627
"xorm.io/xorm"
@@ -116,6 +117,7 @@ func (cfg *SMTPConfig) ToDB() ([]byte, error) {
116117
// PAMConfig holds configuration for the PAM login source.
117118
type PAMConfig struct {
118119
ServiceName string // pam service (e.g. system-auth)
120+
EmailDomain string
119121
}
120122

121123
// FromDB fills up a PAMConfig from serialized format.
@@ -696,15 +698,26 @@ func LoginViaPAM(user *User, login, password string, sourceID int64, cfg *PAMCon
696698

697699
// Allow PAM sources with `@` in their name, like from Active Directory
698700
username := pamLogin
701+
email := pamLogin
699702
idx := strings.Index(pamLogin, "@")
700703
if idx > -1 {
701704
username = pamLogin[:idx]
702705
}
706+
if ValidateEmail(email) != nil {
707+
if cfg.EmailDomain != "" {
708+
email = fmt.Sprintf("%s@%s", username, cfg.EmailDomain)
709+
} else {
710+
email = fmt.Sprintf("%s@%s", username, setting.Service.NoReplyAddress)
711+
}
712+
if ValidateEmail(email) != nil {
713+
email = gouuid.New().String() + "@localhost"
714+
}
715+
}
703716

704717
user = &User{
705718
LowerName: strings.ToLower(username),
706719
Name: username,
707-
Email: pamLogin,
720+
Email: email,
708721
Passwd: password,
709722
LoginType: LoginPAM,
710723
LoginSource: sourceID,

modules/context/response.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func (r *Response) Write(bs []byte) (int, error) {
4949
return size, err
5050
}
5151
if r.status == 0 {
52-
r.WriteHeader(200)
52+
r.status = http.StatusOK
5353
}
5454
return size, nil
5555
}

modules/git/batch_reader.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -186,17 +186,18 @@ headerLoop:
186186
// constant hextable to help quickly convert between 20byte and 40byte hashes
187187
const hextable = "0123456789abcdef"
188188

189-
// To40ByteSHA converts a 20-byte SHA in a 40-byte slice into a 40-byte sha in place
190-
// without allocations. This is at least 100x quicker that hex.EncodeToString
191-
// NB This requires that sha is a 40-byte slice
192-
func To40ByteSHA(sha []byte) []byte {
189+
// To40ByteSHA converts a 20-byte SHA into a 40-byte sha. Input and output can be the
190+
// same 40 byte slice to support in place conversion without allocations.
191+
// This is at least 100x quicker that hex.EncodeToString
192+
// NB This requires that out is a 40-byte slice
193+
func To40ByteSHA(sha, out []byte) []byte {
193194
for i := 19; i >= 0; i-- {
194195
v := sha[i]
195196
vhi, vlo := v>>4, v&0x0f
196197
shi, slo := hextable[vhi], hextable[vlo]
197-
sha[i*2], sha[i*2+1] = shi, slo
198+
out[i*2], out[i*2+1] = shi, slo
198199
}
199-
return sha
200+
return out
200201
}
201202

202203
// ParseTreeLineSkipMode reads an entry from a tree in a cat-file --batch stream

modules/git/commit_info_nogogit.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ revListLoop:
310310
commits[0] = string(commitID)
311311
}
312312
}
313-
treeID = To40ByteSHA(treeID)
313+
treeID = To40ByteSHA(treeID, treeID)
314314
_, err = batchStdinWriter.Write(treeID)
315315
if err != nil {
316316
return nil, err

0 commit comments

Comments
 (0)