Rescue Encoding::UndefinedConversionError on logger

(shocker-ja:1228)
This commit is contained in:
Mamoru TASAKA 2014-11-07 20:45:08 +09:00
commit 9b7c55abac
2 changed files with 40 additions and 1 deletions

View file

@ -0,0 +1,29 @@
From 9e788e7f2a5b28748b6e55d9444a7e0428461145 Mon Sep 17 00:00:00 2001
From: Kouhei Sutou <kou@clear-code.com>
Date: Mon, 4 Aug 2014 21:37:04 +0900
Subject: [PATCH] logger: replace invalid and undefined characters in encode
error message
[shocker-ja:1228]
Reported by OBATA Akio. Thanks!!!
---
lib/rabbit/logger/stderr.rb | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/lib/rabbit/logger/stderr.rb b/lib/rabbit/logger/stderr.rb
index b5081ab..f2bf450 100644
--- a/lib/rabbit/logger/stderr.rb
+++ b/lib/rabbit/logger/stderr.rb
@@ -13,7 +13,10 @@ def do_log(severity, prog_name, message)
message = message.encode("locale")
rescue EncodingError
format = _("can't convert to current locale from UTF-8: %s")
- $stderr.puts(format % message.encode(format.encoding))
+ sanitized_message = message.encode(format.encoding,
+ :invalid => :replace,
+ :undef => :replace)
+ $stderr.puts(format % sanitized_message)
end
$stderr.puts(format_severity(severity))
$stderr.print("[#{prog_name}]: ") if prog_name

View file

@ -6,7 +6,7 @@ BuildRequires: %1 \
Name: rubygem-%{gem_name}
Version: 2.1.3
Release: 2%{?dist}
Release: 3%{?dist}
Summary: RD-document-based presentation application
# CC-BY: rubykaigi2011-background-white.jpg and
@ -22,6 +22,9 @@ Source0: https://rubygems.org/gems/%{gem_name}-%{version}.gem
Source1: %{name}-2.1.2-test-missing-files.tar.gz
Source10: rabbit.desktop
Source11: rabbit.xml
# http://www.cozmixng.org/~w3ml/index.rb/rabbit-shocker/msg/1228
# https://github.com/rabbit-shocker/rabbit/commit/9e788e7f2a5b28748b6e55d9444a7e0428461145.patch
Patch0: rubygem-rabbit-2.1.3-replace-invalid-character.patch
%BothRequires ruby(release)
BuildRequires: rubygems-devel
@ -65,6 +68,9 @@ Documentation for %{name}
%prep
gem unpack %{SOURCE0}
%setup -q -D -T -n %{gem_name}-%{version}
%patch0 -p1
gem spec %{SOURCE0} -l --ruby > %{gem_name}.gemspec
%build
@ -171,6 +177,10 @@ update-mime-database %{?fedora:-n} %{_datadir}/mime &> /dev/null || :
%doc %{gem_instdir}/sample/
%changelog
* Fri Nov 7 2014 Mamoru TASAKA <mtasaka@fedoraproject.org> - 2.1.3-3
- Rescue Encoding::UndefinedConversionError on logger
(shocker-ja:1228)
* Thu Oct 02 2014 Rex Dieter <rdieter@fedoraproject.org> 2.1.3-2
- update desktop/icon/mime scriptlets