[Rt-commit] rt branch, 4.2/add-charset-to-content-types, created. rt-4.1.5-11-g2b6c62b

Thomas Sibley trs at bestpractical.com
Fri Dec 7 21:28:59 EST 2012


The branch, 4.2/add-charset-to-content-types has been created
        at  2b6c62b47a3efa14617006aebd093b3f4ce516cd (commit)

- Log -----------------------------------------------------------------
commit 2b6c62b47a3efa14617006aebd093b3f4ce516cd
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Fri Dec 7 17:30:37 2012 -0800

    Add UTF-8 charsets to all textual Content-Types
    
    Whenever the default Content-Type set in HandleRequest() from
    RT::Interface::Web is overridden, the default utf-8 character set
    parameter was lost.  When it comes to encodings, being explicit is best.

diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm
index 184c1c9..08824aa 100644
--- a/lib/RT/Interface/Web.pm
+++ b/lib/RT/Interface/Web.pm
@@ -296,7 +296,7 @@ sub HandleRequest {
 
             # REST urls get a special 401 response
             if ($m->request_comp->path =~ m{^/REST/\d+\.\d+/}) {
-                $HTML::Mason::Commands::r->content_type("text/plain");
+                $HTML::Mason::Commands::r->content_type("text/plain; charset=utf-8");
                 $m->error_format("text");
                 $m->out("RT/$RT::VERSION 401 Credentials required\n");
                 $m->out("\n$msg\n") if $msg;
diff --git a/share/html/Download/CustomFieldValue/dhandler b/share/html/Download/CustomFieldValue/dhandler
index 6db45ed..605b7d1 100644
--- a/share/html/Download/CustomFieldValue/dhandler
+++ b/share/html/Download/CustomFieldValue/dhandler
@@ -61,13 +61,13 @@ unless ($OCFV->id) {
     Abort("Bad OCFV id. Couldn't find OCFV '$id'\n");
 }
 
-my $content_type = $OCFV->ContentType || 'text/plain';
+my $content_type = $OCFV->ContentType || 'text/plain; charset=utf-8';
     
 if (RT->Config->Get('AlwaysDownloadAttachments')) {
     $r->headers_out->{'Content-Disposition'} = "attachment; filename=" . $OCFV->Content;
 }
 elsif (!RT->Config->Get('TrustHTMLAttachments')) {
-    $content_type = 'text/plain' if ($content_type =~ /^text\/html/i);
+    $content_type = 'text/plain; charset=utf-8' if ($content_type =~ /^text\/html/i);
 }
 
 $r->content_type( $content_type );
diff --git a/share/html/Elements/Error b/share/html/Elements/Error
index 04998c7..ce1e256 100644
--- a/share/html/Elements/Error
+++ b/share/html/Elements/Error
@@ -85,7 +85,7 @@ Encode::_utf8_off($error);
 $RT::Logger->error($error);
 
 if ( $session{'REST'} ) {
-    $r->content_type('text/plain');
+    $r->content_type('text/plain; charset=utf-8');
     $m->out( "Error: " . $Why . "\n" );
     $m->out( $Details . "\n" ) if defined $Details && length $Details;
     $m->abort();
diff --git a/share/html/Helpers/Autocomplete/CustomFieldValues b/share/html/Helpers/Autocomplete/CustomFieldValues
index 887302f..4a7f776 100644
--- a/share/html/Helpers/Autocomplete/CustomFieldValues
+++ b/share/html/Helpers/Autocomplete/CustomFieldValues
@@ -45,7 +45,7 @@
 %# those contributions and any derivatives thereof.
 %#
 %# END BPS TAGGED BLOCK }}}
-% $r->content_type('application/json');
+% $r->content_type('application/json; charset=utf-8');
 <% JSON( \@suggestions ) |n %>
 % $m->abort;
 <%INIT>
@@ -53,7 +53,7 @@
 my $term = (split /\n/, $ARGS{term} || '')[-1];
 
 my $abort = sub {
-    $r->content_type('application/json');
+    $r->content_type('application/json; charset=utf-8');
     $m->out(JSON::to_json( [] ));
     $m->abort;
 };
diff --git a/share/html/Helpers/Autocomplete/Groups b/share/html/Helpers/Autocomplete/Groups
index e8baf53..a90ad98 100644
--- a/share/html/Helpers/Autocomplete/Groups
+++ b/share/html/Helpers/Autocomplete/Groups
@@ -45,7 +45,7 @@
 %# those contributions and any derivatives thereof.
 %#
 %# END BPS TAGGED BLOCK }}}
-% $r->content_type('application/json');
+% $r->content_type('application/json; charset=utf-8');
 <% JSON( \@suggestions ) |n %>
 % $m->abort;
 <%ARGS>
diff --git a/share/html/Helpers/Autocomplete/Owners b/share/html/Helpers/Autocomplete/Owners
index 1d065f2..0ac94b0 100644
--- a/share/html/Helpers/Autocomplete/Owners
+++ b/share/html/Helpers/Autocomplete/Owners
@@ -45,7 +45,7 @@
 %# those contributions and any derivatives thereof.
 %#
 %# END BPS TAGGED BLOCK }}}
-% $r->content_type('application/json');
+% $r->content_type('application/json; charset=utf-8');
 <% JSON( \@suggestions ) |n %>
 % $m->abort;
 <%ARGS>
diff --git a/share/html/Helpers/Autocomplete/Users b/share/html/Helpers/Autocomplete/Users
index c2b92c1..a71b7e6 100644
--- a/share/html/Helpers/Autocomplete/Users
+++ b/share/html/Helpers/Autocomplete/Users
@@ -45,7 +45,7 @@
 %# those contributions and any derivatives thereof.
 %#
 %# END BPS TAGGED BLOCK }}}
-% $r->content_type('application/json');
+% $r->content_type('application/json; charset=utf-8');
 <% JSON( \@suggestions ) |n %>
 % $m->abort;
 <%ARGS>
diff --git a/share/html/NoAuth/css/autohandler b/share/html/NoAuth/css/autohandler
index c083444..0e94893 100644
--- a/share/html/NoAuth/css/autohandler
+++ b/share/html/NoAuth/css/autohandler
@@ -59,7 +59,7 @@ elsif ($file =~ /\.(?:htc)$/i) {
     return();
 } else {
     RT::Interface::Web::StaticFileHeaders();
-    $r->content_type('text/css') ;
+    $r->content_type('text/css; charset=utf-8') ;
     $m->call_next();
     return();
 }
diff --git a/share/html/NoAuth/js/autohandler b/share/html/NoAuth/js/autohandler
index 451bf67..15cd267 100644
--- a/share/html/NoAuth/js/autohandler
+++ b/share/html/NoAuth/js/autohandler
@@ -55,7 +55,7 @@ if ($file =~ /\.(gif|png|jpe?g)$/i) {
     RT::Interface::Web->SendStaticFile( File => $file, RelativeFile => $relfile );
 } else {
     &RT::Interface::Web::StaticFileHeaders();
-    $r->content_type('application/x-javascript');
+    $r->content_type('application/x-javascript; charset=utf-8');
     $m->call_next();
     return();
 }
diff --git a/share/html/Search/Elements/ResultsRSSView b/share/html/Search/Elements/ResultsRSSView
index 5033c8c..0f5e84e 100644
--- a/share/html/Search/Elements/ResultsRSSView
+++ b/share/html/Search/Elements/ResultsRSSView
@@ -96,7 +96,7 @@ if ($OrderBy =~ /\|/) {
 } else {
     $Tickets->OrderBy(FIELD => $OrderBy, ORDER => $Order);
 }
-$r->content_type('application/rss+xml');
+$r->content_type('application/rss+xml; charset=utf-8');
 
 
 
diff --git a/share/html/m/style.css b/share/html/m/style.css
index 3912e47..7f8a78e 100644
--- a/share/html/m/style.css
+++ b/share/html/m/style.css
@@ -46,7 +46,7 @@
 %#
 %# END BPS TAGGED BLOCK }}}
 <%init>
-    $HTML::Mason::Commands::r->content_type('text/css');
+    $HTML::Mason::Commands::r->content_type('text/css; charset=utf-8');
     $m->comp('/m/_elements/raw_style');
     $m->abort();
 </%init>

-----------------------------------------------------------------------


More information about the Rt-commit mailing list