Changeset 2890
- Timestamp:
- 08/04/08 11:28:44 (4 months ago)
- Files:
-
- branches/release-42/lib/MT/App.pm (modified) (4 diffs)
- branches/release-42/lib/MT/App/Trackback.pm (modified) (2 diffs)
- branches/release-42/lib/MT/CMS/Category.pm (modified) (1 diff)
- branches/release-42/lib/MT/CMS/Common.pm (modified) (1 diff)
- branches/release-42/lib/MT/CMS/Search.pm (modified) (1 diff)
- branches/release-42/lib/MT/CMS/Tag.pm (modified) (1 diff)
- branches/release-42/lib/MT/CMS/Tools.pm (modified) (1 diff)
- branches/release-42/mt-static/js/tc/client.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/release-42/lib/MT/App.pm
r2877 r2890 3 3 # GNU General Public License, version 2. 4 4 # 5 # $Id : App.pm 2846 2008-07-28 02:46:54Z fumiakiy$5 # $Id$ 6 6 7 7 package MT::App; … … 816 816 my $charset = $app->charset; 817 817 require Encode; 818 require MT::I18N::default; 818 819 $charset = 'UTF-8' if $charset =~ m/utf-?8/i; 820 my $request_charset = $charset; 821 if ( my $content_type = $q->content_type() ) { 822 if ( $content_type =~ m/;[ ]+charset=(.+)/i ) { 823 $request_charset = lc $1; 824 $request_charset =~ s/^\s+|\s+$//gs; 825 } 826 } 827 my $transcode = $request_charset ne $charset ? 1 : 0; 828 my %params; 819 829 foreach my $p (@p) { 820 830 if ( $p =~ m/[^\x20-\x7E]/ ) { … … 825 835 826 836 my @d = $q->param($p); 837 my @param; 827 838 foreach my $d (@d) { 828 next 829 if ( !defined $d ) 830 || ( $d eq '' ) 831 || ( $d !~ m/[^\x20-\x7E]/ ); 839 if ( ( !defined $d ) 840 || ( $d eq '' ) 841 || ( $d !~ m/[^\x20-\x7E]/ ) ) 842 { 843 push @param, $d if $transcode; 844 next; 845 } 846 $d = MT::I18N::default->encode_text_encode( $d, $request_charset, $charset ) 847 if $transcode; 848 my $saved = $d; 832 849 eval { Encode::decode( $charset, $d, 1 ); }; 833 850 return $app->errtrans( … … 835 852 $charset 836 853 ) if $@; 837 } 838 } 854 push @param, $saved if $transcode; 855 } 856 if ( $transcode && @param ) { 857 if ( 1 == scalar(@param) ) { 858 $params{ $p } = $param[0]; 859 } 860 else { 861 $params{ $p } = [ @param ]; 862 } 863 } 864 } 865 $app->param( $_, $params{ $_ } ) foreach keys %params; 839 866 840 867 return 1; branches/release-42/lib/MT/App/Trackback.pm
r2877 r2890 39 39 40 40 # attempt to determine character set encoding based on 41 # 'charset' parameter or 'charset' in content-type header:41 # 'charset' parameter: 42 42 my $enc = $q->param('charset'); 43 unless ($enc) {44 my $content_type = $q->content_type();45 if ( $content_type =~ m/;[ ]+charset=(.+)/i ) {46 $enc = lc $1;47 $enc =~ s/^\s+|\s+$//gs;48 }49 }50 43 local $app->{charset} = $enc if $enc; 51 44 return $app->SUPER::validate_request_params(); … … 253 246 } 254 247 255 my ( $title, $excerpt, $url, $blog_name , $enc)248 my ( $title, $excerpt, $url, $blog_name ) 256 249 = map scalar $q->param($_), 257 qw( title excerpt url blog_name charset); 258 259 unless ($enc) { 260 my $content_type = $q->content_type(); 261 if ( $content_type =~ m/;[ ]+charset=(.+)/i ) { 262 $enc = lc $1; 263 $enc =~ s/^\s+|\s+$//gs; 264 } 265 } 250 qw( title excerpt url blog_name); 266 251 267 252 no_utf8( $tb_id, $title, $excerpt, $url, $blog_name ); 268 269 # guess encoding as possible270 $enc = MT::I18N::guess_encoding( $excerpt . $title . $blog_name )271 unless $enc;272 ( $title, $excerpt, $blog_name )273 = map { encode_text( $_, $enc ) } ( $title, $excerpt, $blog_name );274 253 275 254 return $app->_response( branches/release-42/lib/MT/CMS/Category.pm
r2657 r2890 276 276 277 277 my $label = $app->param('label'); 278 my $enc = $app->config->PublishCharset;279 280 # XMLHttpRequest always send text in UTF-8... right?281 if ( 'utf-8' ne lc($enc) ) {282 $label = MT::I18N::encode_text( $label, 'utf-8', $enc );283 }284 278 my $basename = $app->param('basename'); 285 279 if ( !defined($label) || ( $label =~ m/^\s*$/ ) ) { branches/release-42/lib/MT/CMS/Common.pm
r2502 r2890 450 450 my $data = $sess_obj->thaw_data; 451 451 if ($data) { 452 453 # XMLHttpRequest always send text in UTF-8... right? 454 if ( 'utf-8' eq lc($enc) ) { 455 $q->param( $_, $data->{$_} ) for keys %$data; 456 } 457 else { 458 foreach ( keys %$data ) { 459 my $encoded = 460 MT::I18N::encode_text( $data->{$_}, 'utf-8', $enc ); 461 $q->param( $_, $encoded ); 462 } 463 } 452 $q->param( $_, $data->{$_} ) for keys %$data; 464 453 $param{'recovered_object'} = 1; 465 454 } branches/release-42/lib/MT/CMS/Search.pm
r2809 r2890 386 386 ## on it if it's there. 387 387 if ( ($search || '') ne '' ) { 388 my $enc = $app->charset;389 $search = MT::I18N::encode_text( $search, 'utf-8', $enc )390 if ( $enc !~ m/utf-?8/i )391 && ( 'dialog_grant_role' eq $app->param('__mode') );392 388 $search = quotemeta($search) unless $is_regex; 393 389 $search = '(?i)' . $search unless $case; branches/release-42/lib/MT/CMS/Tag.pm
r2454 r2890 156 156 my $obj_class = $app->model($obj_ds) or return; 157 157 my $tag_name = $app->param('tag') or return; 158 if ( 'utf-8' ne lc( $app->config->PublishCharset) ) { 159 $tag_name = MT::I18N::encode_text( $tag_name, 'utf-8', $app->config->PublishCharset ); 160 } 158 161 159 my $tag_obj = 162 160 $tag_class->load( { name => $tag_name }, { binary => { name => 1 } } ); branches/release-42/lib/MT/CMS/Tools.pm
r2770 r2890 1436 1436 my $app = shift; 1437 1437 my $format = $app->param('format'); 1438 my $text = $app->param('text'); 1439 # XMLHttpRequest always send text in UTF-8... right? 1440 if ( defined $text ) { 1441 $text = encode_text($text, 'utf-8', $app->config->PublishCharset); 1442 } 1443 else { 1444 $text = '' ; 1445 } 1446 my $text_more = $app->param('text_more'); 1447 if ( defined $text_more ) { 1448 $text_more = encode_text($text_more, 'utf-8', $app->config->PublishCharset); 1449 } 1450 else { 1451 $text_more = '' ; 1452 } 1438 my $text = $app->param('text') || ''; 1439 my $text_more = $app->param('text_more') || ''; 1453 1440 my $result = { 1454 1441 text => $app->apply_text_filters( $text, [$format] ), branches/release-42/mt-static/js/tc/client.js
r1174 r2890 89 89 contents = args.join('&'); 90 90 } 91 c.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded ' );91 c.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8' ); 92 92 } 93 93 c.send( contents );
