[arch-commits] Commit in itstool/trunk (3 files)
Jan Steffens
heftig at gemini.archlinux.org
Mon Nov 8 18:46:35 UTC 2021
Date: Monday, November 8, 2021 @ 18:46:35
Author: heftig
Revision: 427524
2.0.7-1
Added:
itstool/trunk/0001-Fix-the-crash-from-912099.patch
(from rev 427523, itstool/trunk/itstool-2.0.5-fix-crash-wrong-encoding.patch)
Modified:
itstool/trunk/PKGBUILD
Deleted:
itstool/trunk/itstool-2.0.5-fix-crash-wrong-encoding.patch
----------------------------------------------+
0001-Fix-the-crash-from-912099.patch | 90 +++++++++++++++++++++++++
PKGBUILD | 14 +--
itstool-2.0.5-fix-crash-wrong-encoding.patch | 68 ------------------
3 files changed, 97 insertions(+), 75 deletions(-)
Copied: itstool/trunk/0001-Fix-the-crash-from-912099.patch (from rev 427523, itstool/trunk/itstool-2.0.5-fix-crash-wrong-encoding.patch)
===================================================================
--- 0001-Fix-the-crash-from-912099.patch (rev 0)
+++ 0001-Fix-the-crash-from-912099.patch 2021-11-08 18:46:35 UTC (rev 427524)
@@ -0,0 +1,90 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Tanguy Ortolo <tanguy+debian at ortolo.eu>
+Date: Fri, 7 Dec 2018 00:00:00 +0000
+Subject: [PATCH] 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
+---
+ itstool.in | 21 +++++++++++++++++----
+ 1 file changed, 17 insertions(+), 4 deletions(-)
+
+diff --git a/itstool.in b/itstool.in
+index c21ad4bfeb86..f34673581c88 100755
+--- a/itstool.in
++++ b/itstool.in
+@@ -44,9 +44,22 @@ if PY3:
+ 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/'
+@@ -1077,36 +1090,36 @@ class Document (object):
+ 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):
+ children = [child for child in xml_child_iter(node)]
+ for child in children:
+ if child.type != 'element':
+ continue
+ if child.ns() is not None and child.ns().content == NS_BLANK:
+ ph_node = msg.get_placeholder(child.name).node
+ if self.has_child_elements(ph_node):
+ self.merge_translations(translations, None, ph_node, strict=strict)
+ newnode = ph_node.copyNode(1)
+ newnode.setTreeDoc(self._doc)
+ child.replaceNode(newnode)
+ else:
+ repl = self.get_translated(ph_node, translations, strict=strict, lang=lang)
+ child.replaceNode(repl)
+ scan_node(child)
+ try:
+ scan_node(trnode)
+ except:
+ 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
Modified: PKGBUILD
===================================================================
--- PKGBUILD 2021-11-08 18:45:58 UTC (rev 427523)
+++ PKGBUILD 2021-11-08 18:46:35 UTC (rev 427524)
@@ -2,8 +2,8 @@
# Contributor: Michael Pusterhofer <pusterhofer(at)student(dot)tugraz(dot)at>
pkgname=itstool
-pkgver=2.0.6
-pkgrel=2
+pkgver=2.0.7
+pkgrel=1
epoch=1
pkgdesc="XML to PO and back again"
arch=(any)
@@ -11,11 +11,11 @@
license=(GPL3)
depends=(python libxml2 docbook-xml)
makedepends=(git)
-_commit=60f3a955ca047b1d62a1d952beec74afaff7cbbf # tags/2.0.6^0
+_commit=f1c6544dcd83a73a5ccea9e0c48cf9a47e006190 # tags/2.0.7^0
source=("git+https://github.com/itstool/itstool#commit=$_commit"
- itstool-2.0.5-fix-crash-wrong-encoding.patch)
+ 0001-Fix-the-crash-from-912099.patch)
sha256sums=('SKIP'
- 'cb57e3694ab3d7c62b063629b2e9edc6327260c0797d0f33c8dc97fe37c40ebb')
+ 'b43cea38118aaefa6724136d142dcc7099cd6de04cf2e226f53d4310dfe207cc')
pkgver() {
cd $pkgname
@@ -25,8 +25,8 @@
prepare() {
cd $pkgname
- # From https://src.fedoraproject.org/rpms/libxml2/tree/master
- patch -Np1 -i ../itstool-2.0.5-fix-crash-wrong-encoding.patch
+ # https://src.fedoraproject.org/rpms/itstool/blob/rawhide/f/itstool-2.0.5-fix-crash-wrong-encoding.patch
+ git apply -3 ../0001-Fix-the-crash-from-912099.patch
autoreconf -fvi
}
Deleted: itstool-2.0.5-fix-crash-wrong-encoding.patch
===================================================================
--- itstool-2.0.5-fix-crash-wrong-encoding.patch 2021-11-08 18:45:58 UTC (rev 427523)
+++ itstool-2.0.5-fix-crash-wrong-encoding.patch 2021-11-08 18:46:35 UTC (rev 427524)
@@ -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 at 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
More information about the arch-commits
mailing list