[Rt-commit] rt branch, 4.4/utf8-internal-encoding-issue, created. rt-4.4.1-327-ga3ebf02

Dave Goehrig dave at bestpractical.com
Thu Mar 30 13:52:14 EDT 2017


The branch, 4.4/utf8-internal-encoding-issue has been created
        at  a3ebf0245192d4a3b908d073c0dbe4d5dd04e921 (commit)

- Log -----------------------------------------------------------------
commit a3ebf0245192d4a3b908d073c0dbe4d5dd04e921
Author: Dave Goehrig <dave at bestpractical.com>
Date:   Tue Mar 28 14:47:28 2017 -0400

    Preload UTF-8 encoding module
    
    After review, Alex pointed out that the root error was Encode::encode
    failing to load the encoding due to internal state problems in perl.
    This patch pre-loads the encoding before setting up the sig __WARN__
    handler.  This will avoid the Encode failing to load.  It should
    be noted that Carp.pm too needs to be preloaded or it too can fail
    at runtime inside of Encode::encode.
    
    Lastly, because Encode::encode is called without checking enabled,
    any UTF-8 strict encoding errors are discarded as warnings are disabled
    and the encoding warnings are themselves reissued witha
    warnings::warnif. If the encoding warnings need to be debuged the
    check paramter Encode::LEAVE_SRC should be passed to Encode::encode.
    This will then log the original message.  This might be a useful debug
    option.
    
    Fixes: I#32648

diff --git a/lib/RT.pm b/lib/RT.pm
index e8a14c0..2291aa0 100644
--- a/lib/RT.pm
+++ b/lib/RT.pm
@@ -245,6 +245,11 @@ sub InitLogging {
 
     unless ( $RT::Logger ) {
 
+        # preload UTF-8 encoding so that Encode:encode doesn't fail to load
+        # it should be noted Encode::encode silently throws away any error
+        # messages with non-UTF-8 strict encoding
+        Encode::encode("UTF-8","");
+
         $RT::Logger = Log::Dispatch->new;
 
         my $stack_from_level;

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


More information about the rt-commit mailing list