From: Jakub Bogusz Date: Mon, 4 May 2020 19:42:42 +0000 (+0200) Subject: - added fix-crash-wrong-encoding patch from Fedora; release 2 X-Git-Tag: auto/th/itstool-2.0.6-2 X-Git-Url: http://git.pld-linux.org/gitweb.cgi?a=commitdiff_plain;h=26c25ac4e3cfed3f0e31bed65a59d6bbef88333b;p=packages%2Fitstool.git - added fix-crash-wrong-encoding patch from Fedora; release 2 --- diff --git a/itstool-fix-crash-wrong-encoding.patch b/itstool-fix-crash-wrong-encoding.patch new file mode 100644 index 0000000..46577d0 --- /dev/null +++ b/itstool-fix-crash-wrong-encoding.patch @@ -0,0 +1,68 @@ +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 +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 diff --git a/itstool.spec b/itstool.spec index 47efe81..bf71601 100644 --- a/itstool.spec +++ b/itstool.spec @@ -2,12 +2,16 @@ Summary: ITS-based XML translation tool Summary(pl.UTF-8): Narzędzie do tłumaczenia XML-a oparte na ITS Name: itstool Version: 2.0.6 -Release: 1 +Release: 2 License: GPL v3+ Group: Applications/Text Source0: http://files.itstool.org/itstool/%{name}-%{version}.tar.bz2 # Source0-md5: 4306eeba4f4aee6b393d14f9c3c57ca1 +Patch0: %{name}-fix-crash-wrong-encoding.patch URL: http://itstool.org/ +BuildRequires: python >= 1:2.6 +BuildRequires: python-libxml2 +Requires: python >= 1:2.6 Requires: python-libxml2 BuildArch: noarch BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n) @@ -25,9 +29,11 @@ komunikaty w pliku PO. %prep %setup -q +%patch0 -p1 %build -%configure +%configure \ + PYTHON="%{__python}" %{__make} %install