Skip to content

Commit 02b764b

Browse files
authored
Merge branch 'main' into dependabot/go_modules/golang.org/x/net-0.36.0
2 parents fd0cd7a + db3f862 commit 02b764b

File tree

3 files changed

+18
-12
lines changed

3 files changed

+18
-12
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ $ curl -v --upload-file ./hello.txt https://transfer.sh/hello.txt
2424
### Encrypt & Upload:
2525
```bash
2626
$ gpg --armor --symmetric --output - /tmp/hello.txt | curl --upload-file - https://transfer.sh/test.txt
27-
````
27+
```
2828

2929
### Download & Decrypt:
3030
```bash
@@ -56,13 +56,13 @@ $ curl --upload-file ./hello.txt https://transfer.sh/hello.txt -H "Max-Days: 1"
5656
### X-Encrypt-Password
5757
#### Beware, use this feature only on your self-hosted server: trusting a third-party service for server side encryption is at your own risk
5858
```bash
59-
$ curl --upload-file ./hello.txt https://your-transfersh-instance.tld/hello.txt -H "X-Encrypt-Password: test" # Encrypt the content sever side with AES265 using "test" as password
59+
$ curl --upload-file ./hello.txt https://your-transfersh-instance.tld/hello.txt -H "X-Encrypt-Password: test" # Encrypt the content server side with AES256 using "test" as password
6060
```
6161

6262
### X-Decrypt-Password
6363
#### Beware, use this feature only on your self-hosted server: trusting a third-party service for server side encryption is at your own risk
6464
```bash
65-
$ curl https://your-transfersh-instance.tld/BAYh0/hello.txt -H "X-Decrypt-Password: test" # Decrypt the content sever side with AES265 using "test" as password
65+
$ curl https://your-transfersh-instance.tld/BAYh0/hello.txt -H "X-Decrypt-Password: test" # Decrypt the content server side with AES256 using "test" as password
6666
```
6767

6868
## Response Headers
@@ -128,7 +128,7 @@ basedir | path storage for local/gdrive provider
128128
gdrive-client-json-filepath | path to oauth client json config for gdrive provider | | GDRIVE_CLIENT_JSON_FILEPATH |
129129
gdrive-local-config-path | path to store local transfer.sh config cache for gdrive provider | | GDRIVE_LOCAL_CONFIG_PATH |
130130
gdrive-chunk-size | chunk size for gdrive upload in megabytes, must be lower than available memory (8 MB) | | GDRIVE_CHUNK_SIZE |
131-
lets-encrypt-hosts | hosts to use for lets encrypt certificates (comma seperated) | | HOSTS |
131+
lets-encrypt-hosts | hosts to use for lets encrypt certificates (comma separated) | | HOSTS |
132132
log | path to log file | | LOG |
133133
cors-domains | comma separated list of domains for CORS, setting it enable CORS | | CORS_DOMAINS |
134134
clamav-host | host for clamav feature | | CLAMAV_HOST |

server/server.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ func ProfileListener(s string) OptionFn {
144144
func WebPath(s string) OptionFn {
145145
return func(srvr *Server) {
146146
if s[len(s)-1:] != "/" {
147-
s = s + string(filepath.Separator)
147+
s = filepath.Join(s, "")
148148
}
149149

150150
srvr.webPath = s
@@ -155,7 +155,7 @@ func WebPath(s string) OptionFn {
155155
func ProxyPath(s string) OptionFn {
156156
return func(srvr *Server) {
157157
if s[len(s)-1:] != "/" {
158-
s = s + string(filepath.Separator)
158+
s = filepath.Join(s, "")
159159
}
160160

161161
srvr.proxyPath = s
@@ -173,7 +173,7 @@ func ProxyPort(s string) OptionFn {
173173
func TempPath(s string) OptionFn {
174174
return func(srvr *Server) {
175175
if s[len(s)-1:] != "/" {
176-
s = s + string(filepath.Separator)
176+
s = filepath.Join(s, "")
177177
}
178178

179179
srvr.tempPath = s
@@ -436,8 +436,8 @@ func (s *Server) Run() {
436436

437437
fs = http.Dir(s.webPath)
438438

439-
htmlTemplates, _ = htmlTemplates.ParseGlob(s.webPath + "*.html")
440-
textTemplates, _ = textTemplates.ParseGlob(s.webPath + "*.txt")
439+
htmlTemplates, _ = htmlTemplates.ParseGlob(filepath.Join(s.webPath, "*.html"))
440+
textTemplates, _ = textTemplates.ParseGlob(filepath.Join(s.webPath, "*.txt"))
441441
} else {
442442
fs = &assetfs.AssetFS{
443443
Asset: web.Asset,

server/token.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,24 @@ THE SOFTWARE.
2424

2525
package server
2626

27+
import (
28+
"strings"
29+
)
30+
2731
const (
2832
// SYMBOLS characters used for short-urls
2933
SYMBOLS = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
3034
)
3135

3236
// generate a token
3337
func token(length int) string {
34-
result := ""
38+
var builder strings.Builder
39+
builder.Grow(length)
40+
3541
for i := 0; i < length; i++ {
3642
x := theRand.Intn(len(SYMBOLS) - 1)
37-
result = string(SYMBOLS[x]) + result
43+
builder.WriteByte(SYMBOLS[x])
3844
}
3945

40-
return result
46+
return builder.String()
4147
}

0 commit comments

Comments
 (0)