Skip to content

Commit 61e0bf7

Browse files
committed
Merge remote-tracking branch 'origin/main' into feature/admin_ui
2 parents 502bf34 + af0b6a3 commit 61e0bf7

File tree

7 files changed

+64
-39
lines changed

7 files changed

+64
-39
lines changed

backend/server/auth/handlers.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ func AccountHandler(w http.ResponseWriter, req *http.Request, id string) {
164164
return
165165
}
166166

167-
obscuredEmail, _ := utils.ObscureEmail(user.Email)
167+
obscuredEmail, _ := shared.ObscureEmail(user.Email)
168168
_ = json.NewEncoder(w).Encode(shared.AccountResponse{
169169
Email: obscuredEmail,
170170
PaymentID: user.PaymentID,

backend/server/html/handlers.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212
"yeetfile/backend/server/html/templates"
1313
"yeetfile/backend/server/session"
1414
"yeetfile/backend/server/upgrades"
15-
"yeetfile/backend/utils"
1615
"yeetfile/shared"
1716
"yeetfile/shared/endpoints"
1817
)
@@ -199,7 +198,7 @@ func AccountPageHandler(w http.ResponseWriter, req *http.Request, userID string)
199198

200199
successMsg, errorMsg := generateAccountMessages(req)
201200
hasHint := user.PasswordHint != nil && len(user.PasswordHint) > 0
202-
obscuredEmail, _ := utils.ObscureEmail(user.Email)
201+
obscuredEmail, _ := shared.ObscureEmail(user.Email)
203202
isPrevUpgraded := user.UpgradeExp.Year() >= 2024
204203

205204
isAdmin := auth.IsInstanceAdmin(userID)

backend/server/transfer/upload.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"errors"
55
"github.com/benbusby/b2"
66
"log"
7+
"net/url"
78
db "yeetfile/backend/db"
89
"yeetfile/backend/service"
910
"yeetfile/backend/utils"
@@ -155,12 +156,22 @@ func InitLargeB2Upload(filename string, upload db.B2Upload) error {
155156
return err
156157
}
157158

159+
isDummy := info.Dummy
160+
if !isDummy {
161+
// Ensure that the dummy option is enabled if the request URI
162+
// is not actually valid
163+
_, err = url.ParseRequestURI(upload.UploadURL)
164+
if err != nil {
165+
isDummy = true
166+
}
167+
}
168+
158169
return db.UpdateUploadValues(
159170
upload.MetadataID,
160171
info.UploadURL,
161172
info.AuthorizationToken,
162173
info.FileID, // Multi-chunk files use the file ID for uploading
163-
info.Dummy)
174+
isDummy)
164175
}
165176

166177
func ResetLargeUpload(b2FileID string, metadataID string) (b2.FilePartInfo, error) {

backend/utils/misc.go

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"crypto/sha1"
55
"encoding/base64"
66
"encoding/json"
7-
"errors"
87
"fmt"
98
"io"
109
"log"
@@ -238,36 +237,6 @@ func ParseSizeString(str string) int64 {
238237
return 0
239238
}
240239

241-
// ObscureEmail takes an email and strips out the majority of the address and
242-
// domain, adding "***" as an indicator of the obfuscation for both.
243-
func ObscureEmail(email string) (string, error) {
244-
segments := strings.Split(email, "@")
245-
if len(segments) != 2 {
246-
return "", errors.New("invalid email")
247-
}
248-
249-
address := segments[0]
250-
domain := segments[1]
251-
252-
var hiddenEmail string
253-
if len(address) > 1 {
254-
hiddenEmail = fmt.Sprintf(
255-
"%c%c***%c@%c***.com",
256-
address[0],
257-
address[1],
258-
address[len(address)-1],
259-
domain[0])
260-
} else {
261-
hiddenEmail = fmt.Sprintf(
262-
"%c***%c@%c***.com",
263-
address[0],
264-
address[len(address)-1],
265-
domain[0])
266-
}
267-
268-
return hiddenEmail, nil
269-
}
270-
271240
// LimitedChunkReader reads the request body, limited to max chunk size + encryption
272241
// overhead + 1024 bytes. This is big enough for all data-containing requests
273242
// made to the YeetFile API.

cli/commands/auth/login/login.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package login
22

33
import (
4+
"strings"
45
"yeetfile/cli/crypto"
56
"yeetfile/cli/globals"
67
"yeetfile/cli/utils"
@@ -11,6 +12,9 @@ import (
1112
// generate the login key hash, and stores the user's key pair in their config
1213
// directory
1314
func LogIn(identifier, password, code string, sessionKey, vaultKey []byte) error {
15+
identifier = strings.TrimSpace(identifier)
16+
password = strings.TrimSpace(password)
17+
1418
userKey, loginKeyHash := crypto.GenerateUserKeys(identifier, password)
1519

1620
login := shared.Login{

cross_compile.sh

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,12 @@ do
6767
arch_name="arm32"
6868
fi
6969

70-
tar_name="${output_name}_${GOOS}_${arch_name}_${VER}.tar.gz"
70+
compressed_name="${output_name}_${GOOS}_${arch_name}_${VER}.tar.gz"
7171
if [ $GOOS = "darwin" ]; then
7272
os_name="macOS"
73-
tar_name="${output_name}_macos_${arch_name}_${VER}.tar.gz"
73+
compressed_name="${output_name}_macos_${arch_name}_${VER}.tar.gz"
74+
elif [ $GOOS = "windows" ]; then
75+
compressed_name="${output_name}_windows_${arch_name}_${VER}.zip"
7476
fi
7577

7678
if [ $GOOS = "windows" ]; then
@@ -85,10 +87,14 @@ do
8587
exit 1
8688
fi
8789

88-
tar -czvf out/$tar_name $output_name
90+
if [ $GOOS = "windows" ]; then
91+
zip -j out/$compressed_name $output_name
92+
else
93+
tar -czvf out/$compressed_name $output_name
94+
fi
8995
rm -f $output_name
9096

91-
full_link="$RELEASE_NOTES_LINK/$tar_name"
97+
full_link="$RELEASE_NOTES_LINK/$compressed_name"
9298

9399
printf -- "- $os_name (\`$arch_name\`): [$tar_name]($full_link)\n" >> $RELEASE_NOTES_FILE
94100
done

shared/utils.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package shared
22

33
import (
44
"bufio"
5+
"errors"
56
"fmt"
67
"math"
78
"math/rand"
@@ -184,3 +185,38 @@ func ArrayContains(items []string, target string) bool {
184185
}
185186
return false
186187
}
188+
189+
// ObscureEmail takes an email and strips out the majority of the address and
190+
// domain, adding "***" as an indicator of the obfuscation for both.
191+
func ObscureEmail(email string) (string, error) {
192+
segments := strings.Split(email, "@")
193+
if len(segments) != 2 {
194+
return "", errors.New("invalid email")
195+
}
196+
197+
address := segments[0]
198+
domain := segments[1]
199+
200+
segments = strings.Split(email, ".")
201+
ext := segments[len(segments)-1]
202+
203+
var hiddenEmail string
204+
if len(address) > 1 {
205+
hiddenEmail = fmt.Sprintf(
206+
"%c%c***%c@%c***.%s",
207+
address[0],
208+
address[1],
209+
address[len(address)-1],
210+
domain[0],
211+
ext)
212+
} else {
213+
hiddenEmail = fmt.Sprintf(
214+
"%c***%c@%c***.%s",
215+
address[0],
216+
address[len(address)-1],
217+
domain[0],
218+
ext)
219+
}
220+
221+
return hiddenEmail, nil
222+
}

0 commit comments

Comments
 (0)