move nickname sanitization out
authorJoey Hess <joey@kitenet.net>
Sun, 4 Jul 2010 20:44:38 +0000 (16:44 -0400)
committerJoey Hess <joey@kitenet.net>
Sun, 4 Jul 2010 20:44:38 +0000 (16:44 -0400)
Probably best to store it unsanitized and sanitize as needed on use.
And it already was for comments, leaving only the need to sanitize the
nickname when git committing, to ensure the email address is legal.

IkiWiki/Plugin/git.pm
IkiWiki/Plugin/openid.pm

index 0f92476c94403df7b52a28f62e0f4a17d5988794..cb3437e1861a5a7b7786fabc6011e5c8772346e7 100644 (file)
@@ -517,6 +517,8 @@ sub rcs_commit_staged (@) {
                }
                if (defined $params{session}->param("nickname")) {
                        $u=encode_utf8($params{session}->param("nickname"));
+                       $u=~s/\s+/_/g;
+                       $u=~s/[^-_0-9[:alnum:]]+//g;
                }
                if (defined $u) {
                        $ENV{GIT_AUTHOR_EMAIL}="$u\@web";
index 4727577f342587bc1e99fdc77c8afb1a42bdb91e..b1a9a7a152866090f2008f0c5ef8ba94771a929a 100644 (file)
@@ -211,8 +211,6 @@ sub auth ($$) {
                                }
                        }
                        if (defined $nickname) {
-                               $nickname=~s/\s+/_/g;
-                               $nickname=~s/[^-_0-9[:alnum:]]+//g;
                                $session->param(nickname => $nickname);
                        }
                }