LEMONLDAP::NG : Bug corrections with XML encoding

environments/ppa-mbqj77/deployments/1
Xavier Guimard 18 years ago
parent c6f9bed0e2
commit 7213be43bd
  1. 56
      modules/lemonldap-ng-manager/lib/Lemonldap/NG/Manager.pm
  2. 3
      modules/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Conf.pm
  3. 2
      modules/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/_HTML.pm

@ -141,7 +141,8 @@ sub printXmlConf {
#XMLDecl => "<?xml version='1.0' encoding='iso-8859-1'?>",
RootName => 'tree',
KeyAttr => { item => 'id', username => 'name' },
NoIndent => 1
NoIndent => 1,
NoSort => 0,
);
}
@ -240,14 +241,15 @@ sub buildTree {
&txt_managerPassword, );
if ( $config->{exportedVars} ) {
while ( my ( $n, $att ) = each( %{ $config->{exportedVars} } ) ) {
$exportedVars->{"ev_$indice"} = $self->xmlField( "both", $att, $n );
foreach my $n ( sort keys %{ $config->{exportedVars} } ) {
$exportedVars->{ sprintf( "ev_%010d", $indice) } = $self->xmlField( "both", $config->{exportedVars}->{$n}, $n );
$indice++;
}
}
else {
foreach (qw(mail uid cn)) {
$exportedVars->{$_} = $self->xmlField( 'both', $_, $_ );
foreach (qw(cn mail uid)) {
$exportedVars->{ sprintf( "ev_%010d", $indice) } = $self->xmlField( 'both', $_, $_ );
$indice++;
}
}
@ -257,9 +259,9 @@ sub buildTree {
$tree->{item}->{item}->{generalParameters}->{item}->{sessionStorage}->{item}->{globalStorageOptions}->{item} = {};
$globalStorageOptions =
$tree->{item}->{item}->{generalParameters}->{item}->{sessionStorage}->{item}->{globalStorageOptions}->{item};
while ( my ( $n, $opt ) = each( %{ $config->{globalStorageOptions} } ) )
{
$globalStorageOptions->{$n} = $self->xmlField( "both", $opt, $n );
foreach my $n ( sort keys %{ $config->{globalStorageOptions} } ) {
$globalStorageOptions->{ sprintf( "go_%010d", $indice) } = $self->xmlField( "both", $config->{globalStorageOptions}->{n}, $n );
$indice++;
}
}
else {
@ -269,8 +271,9 @@ sub buildTree {
$tree->{item}->{item}->{virtualHosts}->{item} = {};
my $virtualHost = $tree->{item}->{item}->{virtualHosts}->{item};
# TODO: split locationRules into 2 arrays
while ( my ( $host, $rules ) = each( %{ $config->{locationRules} } ) ) {
my $vh_id = "vh_$indice";
foreach my $host ( sort keys %{ $config->{locationRules} } ) {
my $rules = $config->{locationRules}->{$host};
my $vh_id = sprintf( "vh_%010d", $indice );
$indice++;
$virtualHost->{$vh_id} = $self->xmlField( "text", 'i', $host );
my ( $ih, $ir ) =
@ -279,16 +282,16 @@ sub buildTree {
"$ih" => { text => &txt_httpHeaders, },
"$ir" => { text => &txt_locationRules, },
};
while ( my ( $reg, $expr ) = each(%$rules) ) {
foreach my $reg ( sort keys %$rules ) {
my $type = ( $reg eq 'default' ) ? 'value' : 'both';
$virtualHost->{$vh_id}->{item}->{$ir}->{item}->{"r_$indice"} =
$self->xmlField( $type, $expr, $reg );
$virtualHost->{$vh_id}->{item}->{$ir}->{item}->{ sprintf( "r_%010d", $indice ) } =
$self->xmlField( $type, $rules->{$reg} , $reg );
$indice++;
}
my $headers = $config->{exportedHeaders}->{$host};
while ( my ( $h, $expr ) = each(%$headers) ) {
$virtualHost->{$vh_id}->{item}->{$ih}->{item}->{"h_$indice"} =
$self->xmlField( "both", $expr, $h );
foreach my $h ( sort keys %$headers ) {
$virtualHost->{$vh_id}->{item}->{$ih}->{item}->{ sprintf( "h_%010d", $indice ) } =
$self->xmlField( "both", $headers->{$h}, $h );
$indice++;
}
}
@ -296,16 +299,16 @@ sub buildTree {
if ( $config->{groups} and %{ $config->{groups} } ) {
$tree->{item}->{item}->{groups}->{item} = {};
my $groups = $tree->{item}->{item}->{groups}->{item};
while ( my ( $group, $expr ) = each( %{ $config->{groups} } ) ) {
$groups->{"g_$indice"} = $self->xmlField( 'both', $expr, $group );
foreach my $group ( sort keys %{ $config->{groups} } ) {
$groups->{ sprintf( "g_%010d", $indice) } = $self->xmlField( 'both', $config->{groups}->{$group}, $group );
$indice++;
}
}
if ( $config->{macros} and %{ $config->{macros} } ) {
$tree->{item}->{item}->{generalParameters}->{item}->{macros}->{item} = {};
my $macros = $tree->{item}->{item}->{generalParameters}->{item}->{macros}->{item};
while ( my ( $macro, $expr ) = each( %{ $config->{macros} } ) ) {
$macros->{"m_$indice"} = $self->xmlField( 'both', $expr, $macro );
foreach my $macro ( sort keys %{ $config->{macros} } ) {
$macros->{"m_$indice"} = $self->xmlField( 'both', $config->{macros}->{$macro}, $macro );
$indice++;
}
}
@ -430,6 +433,7 @@ sub checkConf {
my $response = shift;
my $expr = '';
my $result = 1;
my $assign = qr/(?<=[^=<!>\?])=(?![=~])/;
# Check cookie name
unless ( $config->{cookieName} =~ /^[a-zA-Z]\w*$/ ) {
$result = 0;
@ -440,6 +444,10 @@ sub checkConf {
$result = 0;
$response->error( '"' . $config->{domain} . '" ' . &txt_isNotAValidCookieName );
}
# Customized variables
foreach ( @{ $self->{customVars} } ) {
$expr .= "my \$$_ = '1';";
}
# Load variables
foreach ( keys %{ $config->{exportedVars} } ) {
# Reserved words
@ -468,7 +476,7 @@ sub checkConf {
$result = 0;
}
# "=" may be a fault ("==")
if ( $v =~ /(?<=[^=<\?])=(?!=)/ ) {
if ( $v =~ $assign ) {
$response->warning( &txt_macro . " $k " . &txt_containsAnAssignment );
}
# Test macro values;
@ -494,7 +502,7 @@ sub checkConf {
$result = 0;
}
# "=" may be a fault (but not "==")
if ( $v =~ /(?<=[^=<\?])=(?!=)/ ) {
if ( $v =~ $assign ) {
$response->warning( &txt_group . " $k " . &txt_containsAnAssignment );
}
# Test boolean expression
@ -524,7 +532,7 @@ sub checkConf {
# Test boolean expressions
unless ( $v =~ /^(?:accept$|deny$|logout)/ ) {
# "=" may be a fault (but not "==")
if ( $v =~ /(?<=[^=<\?])=(?!=)/ ) {
if ( $v =~ $assign ) {
$response->warning( &txt_rule . " $vh -> \"$reg\" : " . &txt_containsAnAssignment );
}
@ -550,7 +558,7 @@ sub checkConf {
$result = 0;
}
# "=" may be a fault ("==")
if ( $v =~ /(?<=[^=<\?])=(?!=)/ ) {
if ( $v =~ $assign ) {
$response->warning( &txt_header . " $vh -> $header " . &txt_containsAnAssignment );
}
# Perl expression

@ -74,9 +74,8 @@ sub getConf {
my $fields = $self->load( $args->{cfgNum}, $args->{fields} );
my $conf;
while ( my ( $k, $v ) = each(%$fields) ) {
$v =~ s/^'(.*)'$/$1/m;
$v =~ s/^'(.*)'$/$1/s;
if( $k =~ /^(?:exportedVars|locationRules|groups|exportedHeaders|macros|globalStorageOptions)$/ ) {
my $data1;
if ( $v !~ /^\$/ ) {
print STDERR "Lemonldap::NG : Warning: configuration is in old format, you've to migrate !\n";
eval 'require Storable;require MIME::Base64;';

@ -396,7 +396,7 @@ function deleteConf(){
function ec(s){
if((!s) || s=='') return s;
return s.replace(/&/g,'&amp;').replace(/>/g,'&gt;').replace(/</g,'&lt;');
return s.replace(/&(?!\#)/g,'&amp;').replace(/>/g,'&gt;').replace(/</g,'&lt;');
}
#;
}

Loading…
Cancel
Save