--- loncom/interface/loncreateuser.pm	2006/11/23 00:04:09	1.137
+++ loncom/interface/loncreateuser.pm	2006/11/23 00:53:19	1.138
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Create a user
 #
-# $Id: loncreateuser.pm,v 1.137 2006/11/23 00:04:09 raeburn Exp $
+# $Id: loncreateuser.pm,v 1.138 2006/11/23 00:53:19 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -216,11 +216,8 @@ END
 # =================================================================== Phase two
 sub print_user_modification_page {
     my $r=shift;
-    my $ccuname=$env{'form.ccuname'};
-    my $ccdomain=$env{'form.ccdomain'};
-
-    $ccuname=~s/\W//g;
-    $ccdomain=~s/\W//g;
+    my $ccuname =&LONCAPA::clean_username($env{'form.ccuname'});
+    my $ccdomain=&LONCAPA::clean_domain($env{'form.ccdomain'});
 
     unless (($ccuname) && ($ccdomain)) {
 	&print_username_entry_form($r);
@@ -238,9 +235,9 @@ sub print_user_modification_page {
                   );
     $loginscript  = &Apache::loncommon::authform_header(%param);
     $authformkrb  = &Apache::loncommon::authform_kerberos(%param);
-
-    $ccuname=~s/\W//g;
-    $ccdomain=~s/\W//g;
+						 
+    $ccuname =&LONCAPA::clean_username($ccuname);
+    $ccdomain=&LONCAPA::clean_domain($ccdomain);
     my $pjump_def = &Apache::lonhtmlcommon::pjump_javascript_definition();
     my $dc_setcourse_code = '';
     my $nondc_setsection_code = '';                                        
@@ -1029,7 +1026,8 @@ sub update_user_data {
 	$r->print($error.&mt('No login name specified').'.'.$end);
 	return;
     }
-    if (  $env{'form.ccuname'}  =~/\W/) {
+    if (  $env{'form.ccuname'} ne 
+	  &LONCAPA::clean_username($env{'form.ccuname'}) ) {
 	$r->print($error.&mt('Invalid login name').'.  '.
 		  &mt('Only letters, numbers, and underscores are valid').'.'.
 		  $end);
@@ -1039,9 +1037,10 @@ sub update_user_data {
 	$r->print($error.&mt('No domain specified').'.'.$end);
 	return;
     }
-    if (  $env{'form.ccdomain'} =~/\W/) {
+    if (  $env{'form.ccdomain'} ne
+	  &LONCAPA::clean_domain($env{'form.ccdomain'}) ) {
 	$r->print($error.&mt ('Invalid domain name').'.  '.
-		  &mt('Only letters, numbers, and underscores are valid').'.'.
+		  &mt('Only letters, numbers, periods, dashes, and underscores are valid').'.'.
 		  $end);
 	return;
     }