Add Cloudflare email and collaboration workflows
This commit is contained in:
@@ -4,10 +4,27 @@ import (
|
||||
"crypto/rand"
|
||||
"crypto/sha256"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"path"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
func NormalizeFolderPath(raw string) (string, error) {
|
||||
raw = strings.TrimSpace(strings.ReplaceAll(raw, "\\", "/"))
|
||||
if raw == "" || raw == "/" {
|
||||
return "", nil
|
||||
}
|
||||
clean := path.Clean(strings.Trim(raw, "/"))
|
||||
if clean == "." {
|
||||
return "", nil
|
||||
}
|
||||
if clean == ".." || strings.HasPrefix(clean, "../") {
|
||||
return "", fmt.Errorf("folder path must remain inside the content root")
|
||||
}
|
||||
return clean, nil
|
||||
}
|
||||
|
||||
func randomID(prefix string) string {
|
||||
buf := make([]byte, 12)
|
||||
if _, err := rand.Read(buf); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user