File tree Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -73,12 +73,15 @@ protected function sanitizeUserIdCandidate(string $rawUidCandidate): string {
73
73
//FIXME: adjusted copy of LDAP's Access::sanitizeUsername(), should go to API
74
74
$ sanitized = trim ($ rawUidCandidate );
75
75
76
- // Transliteration to ASCII
77
- $ transliterated = @iconv ('UTF-8 ' , 'ASCII//TRANSLIT ' , $ sanitized );
78
- if ($ transliterated !== false ) {
79
- // depending on system config iconv can work or not
80
- $ sanitized = $ transliterated ;
81
- }
76
+ // Use htmlentities to get rid of accents
77
+ $ sanitized = htmlentities ($ sanitized , ENT_NOQUOTES , 'UTF-8 ' );
78
+
79
+ // Remove accents
80
+ $ sanitized = preg_replace ('#&([A-Za-z])(?:acute|cedil|caron|circ|grave|orn|ring|slash|th|tilde|uml);# ' , '\1 ' , $ sanitized );
81
+ // Remove ligatures
82
+ $ sanitized = preg_replace ('#&([A-Za-z]{2})(?:lig);# ' , '\1 ' , $ sanitized );
83
+ // Remove unknown leftover entities
84
+ $ sanitized = preg_replace ('#&[^;]+;# ' , '' , $ sanitized );
82
85
83
86
// Replacements
84
87
$ sanitized = str_replace (' ' , '_ ' , $ sanitized );
You can’t perform that action at this time.
0 commit comments