PacketFence - BTS - PacketFence
View Issue Details
0001287PacketFencecaptive portalpublic2011-09-28 13:542011-10-24 20:17
obilodeau 
francis 
normalminorrandom
closedfixed 
Linux
 
3.0.23.0.2 
0001287: Unreliable encoding behavior messes up with translations
Default apache and perl CGI charset is set to ISO-8859-1. It works most of the time but we faced a situation where it didn't.

Can be fixed in two stages:
--- pf/conf/httpd.conf.apache22 a261d69b389f0d9a00a66cd82fdbca52f12f37c3
+++ pf/conf/httpd.conf.apache22 8a42bf3e66bc88774fd73677c32499120b567451
@@ -33,8 +33,7 @@ ErrorLog %%install_dir%%/logs/error_log
 LogFormat "%h %l %u %t \"%r\" %>s %b" common
 LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" 
combined
 ErrorLog %%install_dir%%/logs/error_log
-AddDefaultCharset ISO-8859-1
-AddCharset ISO-8859-1  .iso8859-1  .latin1
+AddDefaultCharset UTF-8
 
 AddHandler cgi-script .cgi
 TypesConfig /etc/mime.types

and change all the instances of print $cgi->header(...
@@ -348,7 +348,7 @@ sub generate_error_page {
     }
 
     my $cookie = $cgi->cookie( CGISESSID => $session->id );
-    print $cgi->header( -cookie => $cookie );
+    print $cgi->header( -cookie => $cookie, -charset => 'utf-8' );
 
     my $template = Template->new( { INCLUDE_PATH => [$CAPTIVE_PORTAL{'TEMPLATE_DIR'}], } );
     $template->process( "error.html", $vars, $r );
No tags attached.
Issue History
2011-09-28 13:54obilodeauNew Issue
2011-09-29 13:36francisNote Added: 0002303
2011-09-29 14:00francisNote Added: 0002304
2011-09-29 14:00francisStatusnew => resolved
2011-09-29 14:00francisResolutionopen => fixed
2011-09-29 14:00francisAssigned To => francis
2011-09-29 14:00francisFixed in Version => +1
2011-10-24 20:15obilodeauTarget Version+1 => 3.0.2
2011-10-24 20:15obilodeauNote Added: 0002388
2011-10-24 20:16obilodeauStatusresolved => closed
2011-10-24 20:17obilodeauFixed in Version+1 => 3.0.2

Notes
(0002303)
francis   
2011-09-29 13:36   
Requires yet another stage :

--- pf/lib/pf/web.pm 0b6066e745fb875d27a1e0ea8d93e2d72d752ccb
+++ pf/lib/pf/web.pm 8e5a95336def8f7ee8738fd138203880f2026d34
@@ -66,7 +66,7 @@ sub i18n {
 sub i18n {
     my $msgid = shift;
 
- return decode_utf8(gettext($msgid));
+ return gettext($msgid);
 }
 
 sub ni18n {
@@ -74,7 +74,7 @@ sub ni18n {
     my $plural = shift;
     my $category = shift;
 
- return decode_utf8(ngettext($singular, $plural, $category));
+ return ngettext($singular, $plural, $category);
 }

Also, instead of changing all the calls to header, we could set the header when creating the cgi object. For example :

--- pf/html/captive-portal/guest-selfregistration.cgi 91dccf02668263b7953a85f1e06e0e8fda88711a
+++ pf/html/captive-portal/guest-selfregistration.cgi 1c338dcf019ddf607dbebc06d6d6ee8c4a55766b
@@ -36,6 +36,7 @@ my $cgi = new CGI;
 Log::Log4perl::MDC->put('tid', 0);
 
 my $cgi = new CGI;
+$cgi->charset('utf-8');
 my $session = new CGI::Session(undef, $cgi, {Directory=>'/tmp'});
 
 my $result;
(0002304)
francis   
2011-09-29 14:00   
Fixed and pushed to org.packetfence.3_0 (revision f2ac1c2baa04bde7d43bfaeeb884b3fa4b84d5ea).
(0002388)
obilodeau   
2011-10-24 20:15   
fix released in 3.0.2