Changeset 3017 for trunk/lib/MT/App.pm

Show
Ignore:
Timestamp:
09/03/08 03:57:13 (15 months ago)
Author:
fumiakiy
Message:

Added the new "charset" registry parameter for application methods. Existence of the parameter forces MT to see the input is encoded in the specified character set. BugId:81158

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/lib/MT/App.pm

    r2940 r3017  
    805805    sub validate_request_params { 
    806806        my $app = shift; 
     807        my ( $options ) = @_; 
    807808 
    808809        $has_encode = eval { require Encode; 1 } ? 1 : 0 
     
    814815        # validate all parameter data matches the expected character set. 
    815816        my @p       = $q->param(); 
    816         my $charset = $app->charset; 
     817        # use specific charset if the application method forces it 
     818        my $charset = $options->{charset} || $app->charset; 
    817819        require Encode; 
    818820        require MT::I18N::default; 
     
    24782480 
    24792481    my ($body); 
     2482    # Declare these variables here for Perl 5.6.x 
     2483    # BugId:79755 
     2484    my ( $mode, $code, $requires_login, 
     2485         $get_method_info, $meth_info, @handlers ); 
    24802486    eval { 
    24812487 
    24822488        # line __LINE__ __FILE__ 
    24832489 
    2484         $app->validate_request_params() or die; 
     2490        $mode = $app->mode || 'default'; 
     2491 
     2492        $requires_login = $app->{requires_login}; 
     2493 
     2494        $get_method_info = sub { 
     2495            $code = $app->handlers_for_mode($mode); 
     2496 
     2497            @handlers = ref($code) eq 'ARRAY' ? @$code : ($code) 
     2498                if defined $code; 
     2499 
     2500            $meth_info = {}; 
     2501            foreach my $code (@handlers) { 
     2502                if ( ref $code eq 'HASH' ) { 
     2503                    $meth_info = $code; 
     2504                    $requires_login 
     2505                        = $requires_login & $meth_info->{requires_login} 
     2506                        if exists $meth_info->{requires_login}; 
     2507                } 
     2508            } 
     2509        }; 
     2510        $get_method_info->(); 
     2511 
     2512        $app->validate_request_params($meth_info) or die; 
    24852513 
    24862514        require MT::Auth; 
     
    25052533        } 
    25062534 
    2507         my $mode = $app->mode || 'default'; 
    2508  
    25092535    REQUEST: 
    25102536        { 
    2511  
    2512             # for Perl 5.6.x BugId:79755 
    2513             $mode = $app->{forward} unless $mode; 
    2514  
    2515             my $requires_login = $app->{requires_login}; 
    2516  
    2517             my $code = $app->handlers_for_mode($mode); 
    2518  
    2519             my @handlers = ref($code) eq 'ARRAY' ? @$code : ($code) 
    2520                 if defined $code; 
    2521  
    2522             foreach my $code (@handlers) { 
    2523                 if ( ref $code eq 'HASH' ) { 
    2524                     my $meth_info = $code; 
    2525                     $requires_login 
    2526                         = $requires_login & $meth_info->{requires_login} 
    2527                         if exists $meth_info->{requires_login}; 
    2528                 } 
    2529             } 
    25302537 
    25312538            if ($requires_login) { 
     
    26212628            if ( my $new_mode = $app->{forward} ) { 
    26222629                $mode = $new_mode; 
     2630                $get_method_info->(); 
    26232631                goto REQUEST; 
    26242632            }