Compare commits

..

No commits in common. 'c9' and 'c8' have entirely different histories.
c9 ... c8

@ -1,68 +0,0 @@
Description: Fix the crash from #912099
ITS Tool 2.0.4 crashes when building some documentation, as reported in
#912099. This comes from translations with invalid XML markup, which ITS Tool
fails to merge (which is not abnormal), and to report these issues, needlessly
encodes the original msgstr from unicode to bytes, causing it to be recoded
using the default ascii codec, which fails when the msgstr contains anything
out of ascii.
.
This patch removes the useless decoding, avoiding the failing subsequent
recoding. It also explicitly encodes the output strings to be able to print
them in all cases, even when the output encoding cannot be detected.
Bug: https://github.com/itstool/itstool/issues/25
Bug-Debian: https://bugs.debian.org/912099
Forwarded: https://github.com/itstool/itstool/issues/25
Author: Tanguy Ortolo <tanguy+debian@ortolo.eu>
Last-Update: 2018-12-071
Index: itstool/itstool.in
===================================================================
--- itstool.orig/itstool.in 2018-12-10 18:31:23.762143539 +0100
+++ itstool/itstool.in 2018-12-10 18:38:03.496777117 +0100
@@ -44,9 +44,22 @@
else:
return str(s)
ustr_type = str
+ def pr_str(s):
+ """Return a string that can be safely print()ed"""
+ # Since print works on both bytes and unicode, just return the argument
+ return s
else:
string_types = basestring,
ustr = ustr_type = unicode
+ def pr_str(s):
+ """Return a string that can be safely print()ed"""
+ if isinstance(s, str):
+ # Since print works on str, just return the argument
+ return s
+ else:
+ # print may not work on unicode if the output encoding cannot be
+ # detected, so just encode with UTF-8
+ return unicode.encode(s, 'utf-8')
NS_ITS = 'http://www.w3.org/2005/11/its'
NS_ITST = 'http://itstool.org/extensions/'
@@ -1060,9 +1073,9 @@
if strict:
raise
else:
- sys.stderr.write('Warning: Could not merge %stranslation for msgid:\n%s\n' % (
+ sys.stderr.write(pr_str('Warning: Could not merge %stranslation for msgid:\n%s\n' % (
(lang + ' ') if lang is not None else '',
- msgstr.encode('utf-8')))
+ msgstr)))
self._xml_err = ''
return node
def scan_node(node):
@@ -1087,9 +1100,9 @@
if strict:
raise
else:
- sys.stderr.write('Warning: Could not merge %stranslation for msgid:\n%s\n' % (
+ sys.stderr.write(pr_str('Warning: Could not merge %stranslation for msgid:\n%s\n' % (
(lang + ' ') if lang is not None else '',
- msgstr.encode('utf-8')))
+ msgstr)))
self._xml_err = ''
ctxt.doc().freeDoc()
return node

@ -1,19 +1,17 @@
Name: itstool
Version: 2.0.6
Release: 7%{?dist}
Release: 2%{?dist}
Summary: ITS-based XML translation tool
Group: Development/Tools
License: GPLv3+
URL: http://itstool.org/
Source0: http://files.itstool.org/itstool/%{name}-%{version}.tar.bz2
# See: https://github.com/itstool/itstool/issues/25
Patch0: https://sources.debian.org/data/main/i/itstool/2.0.5-2/debian/patches/fix_crash_912099.patch#/%{name}-2.0.5-fix-crash-wrong-encoding.patch
BuildArch: noarch
BuildRequires: python3-libxml2
BuildRequires: python3-devel
BuildRequires: make
Requires: python3-libxml2
%description
@ -23,72 +21,38 @@ how to separate it into PO file messages.
%prep
%setup -q
%patch0 -p 1 -b .encoding
%build
export PYTHON=%{__python3}
%configure
%make_build
make %{?_smp_mflags}
%install
%make_install
make install DESTDIR=$RPM_BUILD_ROOT
%files
%license COPYING COPYING.GPL3
%doc NEWS
%doc COPYING COPYING.GPL3 NEWS
%{_bindir}/itstool
%{_datadir}/itstool
%{_mandir}/man1/itstool.1*
%doc %{_mandir}/man1/itstool.1.gz
%changelog
* Mon Aug 09 2021 Mohan Boddu <mboddu@redhat.com> - 2.0.6-7
- Rebuilt for IMA sigs, glibc 2.34, aarch64 flags
Related: rhbz#1991688
* Fri Jun 05 2020 Sundeep Anand <suanand@redhat.com> - 2.0.6-2
- sync with Fedora package
* Fri Apr 16 2021 Mohan Boddu <mboddu@redhat.com> - 2.0.6-6
- Rebuilt for RHEL 9 BETA on Apr 15th 2021. Related: rhbz#1947937
* Tue May 19 2020 Sundeep Anand <suanand@redhat.com> - 2.0.6-1
- Update to 2.0.6 (rhbz#1836152)
- Remove fix-segfaults.patch, as it is a part of upstream now
* Tue Jan 26 2021 Fedora Release Engineering <releng@fedoraproject.org> - 2.0.6-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild
* Sat May 09 2020 Sundeep Anand <suanand@redhat.com> - 2.0.4-3
- rebuild for s390x (rhbz#1800548)
* Tue Jul 28 2020 Fedora Release Engineering <releng@fedoraproject.org> - 2.0.6-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild
* Wed Jan 29 2020 Fedora Release Engineering <releng@fedoraproject.org> - 2.0.6-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild
* Thu Jul 25 2019 Fedora Release Engineering <releng@fedoraproject.org> - 2.0.6-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild
* Sun Apr 07 2019 Kalev Lember <klember@redhat.com> - 2.0.6-1
- Update to 2.0.6
* Fri Feb 01 2019 Fedora Release Engineering <releng@fedoraproject.org> - 2.0.5-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild
* Sun Jan 06 2019 Björn Esser <besser82@fedoraproject.org> - 2.0.5-2
- Add a patch from Debian to fix wrong encoding of output message
* Tue Dec 04 2018 Kalev Lember <klember@redhat.com> - 2.0.5-1
- Update to 2.0.5
- Use make_build and make_install macros
* Mon Jul 16 2018 Charalampos Stratakis <cstratak@redhat.com> - 2.0.4-4
* Mon Jul 16 2018 Charalampos Stratakis <cstratak@redhat.com> - 2.0.4-2
- Fix libxml2 related segfaults
* Mon Jul 16 2018 Miro Hrončok <mhroncok@redhat.com> - 2.0.4-3
- Switch to Python 3
* Fri Jul 13 2018 Fedora Release Engineering <releng@fedoraproject.org> - 2.0.4-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild
* Tue Jul 10 2018 Kalev Lember <klember@redhat.com> - 2.0.4-1
* Sun Jul 08 2018 Charalampos Stratakis <cstratak@redhat.com> - 2.0.4-1
- Update to 2.0.4
- Use license macro for COPYING
* Wed Feb 07 2018 Iryna Shcherbina <ishcherb@redhat.com> - 2.0.2-9
- Update Python 2 dependency declarations to new packaging standards
(See https://fedoraproject.org/wiki/FinalizingFedoraSwitchtoPython3)
- Change to python3
* Mon Feb 05 2018 Petr Viktorin <pviktori@redhat.com> - 2.0.2-8
- Be more explicit about Python build dependencies

Loading…
Cancel
Save