+# Username to display for emailauth accounts.
+sub emailuser ($) {
+ my $user=shift;
+ if (defined $user && $user =~ m/(.+)@/) {
+ my $nick=$1;
+ # remove any characters from not allowed in wiki files
+ # support use w/o %config set
+ my $chars = defined $config{wiki_file_chars} ? $config{wiki_file_chars} : "-[:alnum:]+/.:_";
+ $nick=~s/[^$chars]/_/g;
+ return $nick;
+ }
+ return;
+}
+
+# Some user information should not be exposed in commit metadata, etc.
+# This generates a cloaked form of such information.
+sub cloak ($) {
+ my $user=shift;
+ # cloak email address using http://xmlns.com/foaf/spec/#term_mbox_sha1sum
+ if ($user=~m/(.+)@/) {
+ my $nick=$1;
+ eval q{use Digest::SHA};
+ return $user if $@;
+ return $nick.'@'.Digest::SHA::sha1_hex("mailto:$user");
+ }
+ else {
+ return $user;
+ }
+}
+