aboutsummaryrefslogtreecommitdiff
path: root/appservice
diff options
context:
space:
mode:
Diffstat (limited to 'appservice')
-rw-r--r--appservice/util.go15
1 files changed, 11 insertions, 4 deletions
diff --git a/appservice/util.go b/appservice/util.go
index 4175fb0..160f492 100644
--- a/appservice/util.go
+++ b/appservice/util.go
@@ -2,7 +2,7 @@ package appservice
import (
"fmt"
- "strings"
+ "unicode"
log "github.com/sirupsen/logrus"
@@ -44,8 +44,15 @@ func userMxId(protocol string, id UserID) string {
}
func safeStringForId(in string) string {
- id2 := strings.ReplaceAll(in, "#", "")
- id2 = strings.ReplaceAll(id2, "@", "__")
- id2 = strings.ReplaceAll(id2, ":", "_")
+ id2 := ""
+ for _, c := range in {
+ if c == '@' {
+ id2 += "__"
+ } else if c == ':' {
+ id2 += "_"
+ } else if unicode.IsDigit(c) || unicode.IsLetter(c) {
+ id2 += string(c)
+ }
+ }
return id2
}