mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-03 04:50:52 +08:00
fix(iflow): adjust auth filename email sanitization
This commit is contained in:
@@ -95,14 +95,13 @@ func promptForCookie(promptFn func(string) (string, error)) (string, error) {
|
|||||||
// getAuthFilePath returns the auth file path for the given provider and email
|
// getAuthFilePath returns the auth file path for the given provider and email
|
||||||
func getAuthFilePath(cfg *config.Config, provider, email string) string {
|
func getAuthFilePath(cfg *config.Config, provider, email string) string {
|
||||||
// Clean email to make it filename-safe
|
// Clean email to make it filename-safe
|
||||||
cleanEmail := strings.ReplaceAll(email, "@", "_at_")
|
cleanEmail := strings.ReplaceAll(email, "*", "x")
|
||||||
cleanEmail = strings.ReplaceAll(cleanEmail, ".", "_")
|
|
||||||
cleanEmail = strings.ReplaceAll(cleanEmail, "-", "_")
|
|
||||||
|
|
||||||
// Remove any remaining special characters
|
// Remove any unsafe characters, but allow standard email chars (@, ., -)
|
||||||
var result strings.Builder
|
var result strings.Builder
|
||||||
for _, r := range cleanEmail {
|
for _, r := range cleanEmail {
|
||||||
if (r >= 'a' && r <= 'z') || (r >= 'A' && r <= 'Z') || (r >= '0' && r <= '9') || r == '_' {
|
if (r >= 'a' && r <= 'z') || (r >= 'A' && r <= 'Z') || (r >= '0' && r <= '9') ||
|
||||||
|
r == '_' || r == '@' || r == '.' || r == '-' {
|
||||||
result.WriteRune(r)
|
result.WriteRune(r)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user