Revision 232

Date:
2012/07/24 15:40:01
Author:
ahitrov
Revision Log:
Error-proof JSON eval

Files:

Legend:

 
Added
 
Removed
 
Modified
  • utf8/core/comps/contenido/document.html

     
    104 104 } elsif ( ($class) && (length($class)>0) && (! ref($document)) ) {
    105 105 $document = new $class ($keeper);
    106 106 $new = 1;
    107 my @properties = $document->structure();
    108 foreach my $prop ( @properties ) {
    109 my $attr = $prop->{attr};
    110 ### !!! Если не стандартная переменная, то можем инициализировать
    111 if ( exists $ARGS{$attr} && ! grep { $prop->{attr} eq $_ } qw( class sect_id id delete save clone s_alias activate deactivate p s use_section alpha alpha_search search_by search ) ) {
    112 $document->$attr($ARGS{$attr});
    107 unless ( $save ) {
    108 my @properties = $document->structure();
    109 foreach my $prop ( @properties ) {
    110 my $attr = $prop->{attr};
    111 ### !!! Если не стандартная переменная, то можем инициализировать
    112 if ( exists $ARGS{$attr} && ! grep { $prop->{attr} eq $_ } qw( class sect_id id delete save clone s_alias activate deactivate p s use_section alpha alpha_search search_by search ) ) {
    113 $document->$attr($ARGS{$attr});
    114 }
    113 115 }
    114 116 }
    115 117 }
  • utf8/core/lib/Contenido/Object.pm

     
    1030 1030
    1031 1031 sub eval_json {
    1032 1032 return undef unless ${$_[0]};
    1033 my $value = $json_u->decode( ${$_[0]});
    1033 my $str = ${$_[0]};
    1034 my $chr = substr($str, 0, 1); return $str unless $chr eq '{' || $chr eq '[';
    1035 my $value = $json_u->decode( $str );
    1034 1036 # map { $_ = Encode::encode(\'utf-8\', $_) unless ref $_; } values %$value;
    1035 1037 return $value;
    1036 1038 }