Skip to content

Commit

Permalink
fix #345
Browse files Browse the repository at this point in the history
  • Loading branch information
ddvk committed Nov 30, 2024
1 parent c33ef7e commit 31b6951
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion internal/app/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func (app *App) authMiddleware() gin.HandlerFunc {
c.Set(syncVersionKey, common.Sync10)
}

uid := common.Sanitize(strings.TrimPrefix(claims.Profile.UserID, "auth0|"))
uid := common.SanitizeUid(strings.TrimPrefix(claims.Profile.UserID, "auth0|"))
c.Set(userIDKey, uid)
c.Set(deviceIDKey, claims.DeviceID)
log.Infof("%s UserId: %s deviceId: %s newSync: %t", authLog, uid, claims.DeviceID, isSync15)
Expand Down
6 changes: 6 additions & 0 deletions internal/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"errors"
"hash/crc32"
"io"
"path/filepath"
"regexp"
"strings"

Expand Down Expand Up @@ -55,6 +56,11 @@ func Sanitize(param string) string {
return nameSeparators.ReplaceAllString(param, "")
}

// SanitizeUid
func SanitizeUid(uid string) string {
return filepath.Clean(filepath.Base(uid))
}

// QueryS sanitize the param
func QueryS(param string, c *gin.Context) string {
p := c.Query(param)
Expand Down
2 changes: 1 addition & 1 deletion internal/storage/fs/documents.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func sanitizeFileName(fileName string) string {
}

func (fs *FileSystemStorage) getUserPath(uid string) string {
return filepath.Join(fs.Cfg.DataDir, filepath.Base(userDir), sanitizeFileName(uid))
return filepath.Join(fs.Cfg.DataDir, filepath.Base(userDir), common.SanitizeUid(uid))
}

// gets the blobstorage path
Expand Down
2 changes: 1 addition & 1 deletion internal/ui/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func (app *ReactAppWrapper) authMiddleware() gin.HandlerFunc {
}
}

uid := common.Sanitize(claims.UserID)
uid := common.SanitizeUid(claims.UserID)
c.Set(userIDContextKey, uid)

brid := claims.BrowserID
Expand Down

0 comments on commit 31b6951

Please sign in to comment.