Changeset 2390
- Timestamp:
- 06/08/20 23:07:15 (4 years ago)
- Location:
- trunk/LATMOS-Accounts/lib/LATMOS/Accounts
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases.pm
r2384 r2390 427 427 428 428 if (my $chk = ( 429 lc($otype) eq 'user' || lc($otype) eq 'group') 430 ? LATMOS::Accounts::Utils::check_ug_validity($id)429 lc($otype) eq 'user' || lc($otype) eq 'group') ? LATMOS::Accounts::Utils::check_ug_validity($id) 430 : lc($otype) eq 'nethost' ? LATMOS::Accounts::Utils::check_host_validity($id) 431 431 : LATMOS::Accounts::Utils::check_oid_validity($id)) { 432 432 $self->log(LA_ERR, "Cannot create $otype with ID $id `%s:'", $chk); -
trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/Nethost.pm
r2142 r2390 7 7 use base qw(LATMOS::Accounts::Bases::Sql::objects); 8 8 use LATMOS::Accounts::Log; 9 use LATMOS::Accounts::Utils; 9 10 use LATMOS::Accounts::I18N; 10 11 use Net::IP; … … 111 112 label => l('Aliases'), 112 113 checkinputformat => sub { 113 return $_[0] =~ /^[[:ascii:]]+$/ ? 1 : 0;114 return LATMOS::Accounts::Utils::check_host_validity($_[0]) ? 0 : 1; 114 115 }, 115 116 }, … … 205 206 label => l('Other name'), 206 207 checkinputformat => sub { 207 return $_[0] =~ /^[[:ascii:]]+$/ ? 1 : 0;208 return LATMOS::Accounts::Utils::check_host_validity($_[0]) ? 0 : 1; 208 209 }, 209 210 }, -
trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Utils.pm
r2352 r2390 269 269 } 270 270 271 =head2 check_host_validity($name) 272 273 Check C<$name> is suitable to be used as nethost identifier. Return the error 274 text, undef if no error. 275 276 =cut 277 278 sub check_host_validity { 279 my ($name) = @_; 280 return "leadind space" if ($name =~ /^\s/); 281 return "trailing space" if ($name =~ /\s$/); 282 return "containing space" if ($name =~ /\s/); 283 return "containing underscore" if ($name =~ /_/); 284 285 return; 286 } 287 271 288 =head2 check_ug_validity($name) 272 289
Note: See TracChangeset
for help on using the changeset viewer.