Changeset 2390


Ignore:
Timestamp:
06/08/20 23:07:15 (4 years ago)
Author:
nanardon
Message:

Add nethost name test to allow utf8

Location:
trunk/LATMOS-Accounts/lib/LATMOS/Accounts
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases.pm

    r2384 r2390  
    427427 
    428428    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) 
    431431        : LATMOS::Accounts::Utils::check_oid_validity($id)) { 
    432432        $self->log(LA_ERR, "Cannot create $otype with ID $id `%s:'", $chk); 
  • trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/Nethost.pm

    r2142 r2390  
    77use base qw(LATMOS::Accounts::Bases::Sql::objects); 
    88use LATMOS::Accounts::Log; 
     9use LATMOS::Accounts::Utils; 
    910use LATMOS::Accounts::I18N; 
    1011use Net::IP; 
     
    111112                label => l('Aliases'), 
    112113                checkinputformat => sub { 
    113                     return $_[0] =~ /^[[:ascii:]]+$/ ? 1 : 0; 
     114                    return LATMOS::Accounts::Utils::check_host_validity($_[0]) ? 0 : 1; 
    114115                }, 
    115116            }, 
     
    205206                label => l('Other name'), 
    206207                checkinputformat => sub { 
    207                     return $_[0] =~ /^[[:ascii:]]+$/ ? 1 : 0; 
     208                    return LATMOS::Accounts::Utils::check_host_validity($_[0]) ? 0 : 1; 
    208209                }, 
    209210            }, 
  • trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Utils.pm

    r2352 r2390  
    269269} 
    270270 
     271=head2 check_host_validity($name) 
     272 
     273Check C<$name> is suitable to be used as nethost identifier. Return the error 
     274text, undef if no error. 
     275 
     276=cut 
     277 
     278sub 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 
    271288=head2 check_ug_validity($name) 
    272289 
Note: See TracChangeset for help on using the changeset viewer.