You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@spamassassin.apache.org by bu...@bugzilla.spamassassin.org on 2016/03/12 11:56:50 UTC

[Bug 7305] New: Wide character in syswrite at Logger/Stderr.pm line 86.

https://bz.apache.org/SpamAssassin/show_bug.cgi?id=7305

            Bug ID: 7305
           Summary: Wide character in syswrite at Logger/Stderr.pm line
                    86.
           Product: Spamassassin
           Version: SVN Trunk (Latest Devel Version)
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: trivial
          Priority: P2
         Component: sa-update
          Assignee: dev@spamassassin.apache.org
          Reporter: jidanni@jidanni.org

$ sa-update -D
Wide character in syswrite at
.../perl/5.22.1/Mail/SpamAssassin/Logger/Stderr.pm line 86.

$ env|grep LC
LC_MESSAGES=C
LC_COLLATE=C
LC_CTYPE=zh_TW.UTF-8

Had to use LC_ALL=C sa-update -D to fix it.

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 7305] Wide character in syswrite at Logger/Stderr.pm line 86.

Posted by bu...@bugzilla.spamassassin.org.
https://bz.apache.org/SpamAssassin/show_bug.cgi?id=7305

--- Comment #1 from Mark Martinec <Ma...@ijs.si> ---
I see, it probably comes from the localized date (month) format.
To reproduce:

LC_ALL=zh_TW.UTF-8 perl -MPOSIX -le 'print POSIX::strftime("%b %d
%H:%M",localtime)'
Wide character in print at -e line 1.
 6月 20 12:32

I suppose the sa-update needs the same setlocale as in spamd:

  use POSIX qw(locale_h setsid sigprocmask _exit);
  POSIX::setlocale(LC_TIME,'C');

Actually this also affects spamassassin -D, and probably
sa-learn and sa-compile with debugging enabled.

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 7305] Wide character in syswrite at Logger/Stderr.pm line 86.

Posted by bu...@bugzilla.spamassassin.org.
https://bz.apache.org/SpamAssassin/show_bug.cgi?id=7305

Giovanni Bechis <gi...@paclan.it> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |giovanni@paclan.it

--- Comment #3 from Giovanni Bechis <gi...@paclan.it> ---
Created attachment 5499
  --> https://bz.apache.org/SpamAssassin/attachment.cgi?id=5499&action=edit
use setlocale before printing errors

IMHO a C locale be enforced when logging to stderr, at least for consistency.

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 7305] Wide character in syswrite at Logger/Stderr.pm line 86.

Posted by bu...@bugzilla.spamassassin.org.
https://bz.apache.org/SpamAssassin/show_bug.cgi?id=7305

Mark Martinec <Ma...@ijs.si> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|Undefined                   |4.0.0

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 7305] Wide character in syswrite at Logger/Stderr.pm line 86.

Posted by bu...@bugzilla.spamassassin.org.
https://bz.apache.org/SpamAssassin/show_bug.cgi?id=7305

--- Comment #2 from Mark Martinec <Ma...@ijs.si> ---
> I suppose the sa-update needs the same setlocale as in spamd:

Decided to address the problem where it happens:

--- lib/Mail/SpamAssassin/Logger/Stderr.pm      (revision 1749344)
+++ lib/Mail/SpamAssassin/Logger/Stderr.pm      (working copy)
@@ -72,8 +72,9 @@
   if (!defined $fmt) {
     # default since 3.3.0
     my $now = Time::HiRes::time;
-    $timestamp = sprintf("%s:%06.3f",
-      POSIX::strftime("%b %d %H:%M", localtime($now)), $now-int($now/60)*60);
+    my $datetime = POSIX::strftime("%b %d %H:%M", localtime($now));
+    utf8::encode($datetime)  if utf8::is_utf8($datetime);  # Bug 7305
+    $timestamp = sprintf("%s:%06.3f", $datetime, $now-int($now/60)*60);
     # Bug 6329: %e is not in a POSIX standard, use %d instead and edit
     local $1; $timestamp =~ s/^(\S+\s+)0/$1 /;
   } elsif ($fmt eq '') {

trunk:
  Sending lib/Mail/SpamAssassin/Logger/Stderr.pm
Committed revision 1749361.

The 3.4 is not affected, as it still does a 'use bytes' in most modules,
sweeping the problem under a carpet.


Now, independently of the above, the question remains:
should a stderr logger issue timestamps in environment's local,
or should a C locale be enforced by a program (like what spamd does,
but not the rest of the utilities).

Example:

LC_ALL=zh_TW.UTF-8 spamassassin -D -t <0.msg
 6月 20 18:48:34.235 [42690] dbg: logger: adding facilities: all
 6月 20 18:48:34.235 [42690] dbg: logger: logging level is DBG
 6月 20 18:48:34.235 [42690] dbg: generic: SpamAssassin version 4.0.0-r1694545

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 7305] Wide character in syswrite at Logger/Stderr.pm line 86.

Posted by bu...@bugzilla.spamassassin.org.
https://bz.apache.org/SpamAssassin/show_bug.cgi?id=7305

Giovanni Bechis <gi...@paclan.it> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #5 from Giovanni Bechis <gi...@paclan.it> ---
fixed with commit r1831073

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 7305] Wide character in syswrite at Logger/Stderr.pm line 86.

Posted by bu...@bugzilla.spamassassin.org.
https://bz.apache.org/SpamAssassin/show_bug.cgi?id=7305

Kevin A. McGrail <km...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kmcgrail@apache.org

--- Comment #4 from Kevin A. McGrail <km...@apache.org> ---
+1 to enforcing a C locale when logging to stder

-- 
You are receiving this mail because:
You are the assignee for the bug.