Fix escaping backslashes
This commit is contained in:
parent
8988bbc774
commit
79f476021b
|
@ -0,0 +1,95 @@
|
||||||
|
From b130af4d27aa7d29f2af2b61296abc1bb6ae6d66 Mon Sep 17 00:00:00 2001
|
||||||
|
From: =?UTF-8?q?=3D=3FUTF-8=3Fq=3FPetr=3D20P=3DC3=3DADsa=3DC5=3D99=3F=3D?=
|
||||||
|
<ppisar@redhat.com>
|
||||||
|
Date: Fri, 8 Nov 2013 02:17:08 +0100
|
||||||
|
Subject: [PATCH] Commit 1735f6f53ca19f99c6e9e39496c486af323ba6a8 started to
|
||||||
|
escape all back-slashes which breaks case when lexicon translations contain
|
||||||
|
substition and literals with eval-non-safe characters. E.g. these
|
||||||
|
translations:
|
||||||
|
MIME-Version: 1.0
|
||||||
|
Content-Type: text/plain; charset=UTF-8
|
||||||
|
Content-Transfer-Encoding: 8bit
|
||||||
|
|
||||||
|
"[_1]foo\\n\n" => "[_1]bar\\n\n",
|
||||||
|
'[_1]foo\n' => '[_1]aÄa\n',
|
||||||
|
|
||||||
|
got doubled back-slashes on the maketext() output.
|
||||||
|
|
||||||
|
This patch de-escapes escaped backslashes if the literal is compiled as
|
||||||
|
function argument.
|
||||||
|
|
||||||
|
Fixes RT #120457.
|
||||||
|
|
||||||
|
Signed-off-by: Petr Písař <ppisar@redhat.com>
|
||||||
|
---
|
||||||
|
MANIFEST | 1 +
|
||||||
|
lib/Locale/Maketext.pm | 1 +
|
||||||
|
t/91_backslash.t | 33 +++++++++++++++++++++++++++++++++
|
||||||
|
3 files changed, 35 insertions(+)
|
||||||
|
create mode 100644 t/91_backslash.t
|
||||||
|
|
||||||
|
diff --git a/MANIFEST b/MANIFEST
|
||||||
|
index 32c65ba..b409558 100644
|
||||||
|
--- a/MANIFEST
|
||||||
|
+++ b/MANIFEST
|
||||||
|
@@ -23,5 +23,6 @@ t/50_super.t
|
||||||
|
t/60_super.t
|
||||||
|
t/70_fail_auto.t
|
||||||
|
t/90_utf8.t
|
||||||
|
+t/91_backslash.t See if Locale::Maketext works
|
||||||
|
t/pod.t
|
||||||
|
META.json Module JSON meta-data (added by MakeMaker)
|
||||||
|
diff --git a/lib/Locale/Maketext.pm b/lib/Locale/Maketext.pm
|
||||||
|
index 63e5fba..26efc94 100644
|
||||||
|
--- a/lib/Locale/Maketext.pm
|
||||||
|
+++ b/lib/Locale/Maketext.pm
|
||||||
|
@@ -570,6 +570,7 @@ sub _compile {
|
||||||
|
$c[-1] = ''; # reuse this slot
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
+ $c[-1] =~ s/\\\\/\\/g;
|
||||||
|
push @code, ' $c[' . $#c . "],\n";
|
||||||
|
push @c, ''; # new chunk
|
||||||
|
}
|
||||||
|
diff --git a/t/91_backslash.t b/t/91_backslash.t
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000..f96edd1
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/t/91_backslash.t
|
||||||
|
@@ -0,0 +1,33 @@
|
||||||
|
+#!/usr/bin/perl -Tw
|
||||||
|
+
|
||||||
|
+use strict;
|
||||||
|
+use Test::More tests => 6;
|
||||||
|
+
|
||||||
|
+BEGIN {
|
||||||
|
+ use_ok( 'Locale::Maketext' );
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+use utf8;
|
||||||
|
+
|
||||||
|
+{
|
||||||
|
+ package My::Localize;
|
||||||
|
+ our @ISA = ('Locale::Maketext');
|
||||||
|
+}
|
||||||
|
+{
|
||||||
|
+ package My::Localize::cs_cz;
|
||||||
|
+ our @ISA = ('My::Localize');
|
||||||
|
+ our %Lexicon = (
|
||||||
|
+ '[_1]foo1\n' => '[_1]bar\n',
|
||||||
|
+ '[_1]foo2\n' => '[_1]běr\n',
|
||||||
|
+ 'foo2\n' => 'aěa\n',
|
||||||
|
+ "[_1]foo\\n\n" => "[_1]bar\\n\n",
|
||||||
|
+ );
|
||||||
|
+ keys %Lexicon; # dodges the 'used only once' warning
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+my $lh = My::Localize->get_handle('cs_cz');
|
||||||
|
+isa_ok( $lh, 'My::Localize::cs_cz' );
|
||||||
|
+is( $lh->maketext('[_1]foo1\n', 'arg'), 'argbar\n', 'Safe parameterized' );
|
||||||
|
+is( $lh->maketext('[_1]foo2\n', 'arg'), 'argběr\n', 'Unicode parameterized' );
|
||||||
|
+is( $lh->maketext('foo2\n'), 'aěa\n', 'Unicode literal' );
|
||||||
|
+is( $lh->maketext("[_1]foo\\n\n", 'arg'), "argbar\\n\n", 'new line parameterized' );
|
||||||
|
--
|
||||||
|
1.8.3.1
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
Name: perl-Locale-Maketext
|
Name: perl-Locale-Maketext
|
||||||
Version: 1.23
|
Version: 1.23
|
||||||
Release: 292%{?dist}
|
Release: 293%{?dist}
|
||||||
Summary: Framework for localization
|
Summary: Framework for localization
|
||||||
License: GPL+ or Artistic
|
License: GPL+ or Artistic
|
||||||
Group: Development/Libraries
|
Group: Development/Libraries
|
||||||
URL: http://search.cpan.org/dist/Locale-Maketext/
|
URL: http://search.cpan.org/dist/Locale-Maketext/
|
||||||
Source0: http://www.cpan.org/authors/id/T/TO/TODDR/Locale-Maketext-%{version}.tar.gz
|
Source0: http://www.cpan.org/authors/id/T/TO/TODDR/Locale-Maketext-%{version}.tar.gz
|
||||||
|
# Fix escaping backslashes, bug #1026763, RT#120457
|
||||||
|
Patch0: Locale-Maketext-1.23-Commit-1735f6f53ca19f99c6e9e39496c486af323ba6a8-star.patch
|
||||||
BuildArch: noarch
|
BuildArch: noarch
|
||||||
BuildRequires: perl
|
BuildRequires: perl
|
||||||
BuildRequires: perl(ExtUtils::MakeMaker)
|
BuildRequires: perl(ExtUtils::MakeMaker)
|
||||||
|
@ -44,6 +46,7 @@ producing localized applications.
|
||||||
|
|
||||||
%prep
|
%prep
|
||||||
%setup -q -n Locale-Maketext-%{version}
|
%setup -q -n Locale-Maketext-%{version}
|
||||||
|
%patch0 -p1
|
||||||
|
|
||||||
%build
|
%build
|
||||||
perl Makefile.PL INSTALLDIRS=vendor
|
perl Makefile.PL INSTALLDIRS=vendor
|
||||||
|
@ -63,6 +66,9 @@ make test
|
||||||
%{_mandir}/man3/*
|
%{_mandir}/man3/*
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Mon Nov 11 2013 Petr Pisar <ppisar@redhat.com> - 1.23-293
|
||||||
|
- Fix escaping backslashes (bug #1026763)
|
||||||
|
|
||||||
* Wed Aug 14 2013 Jitka Plesnikova <jplesnik@redhat.com> - 1.23-292
|
* Wed Aug 14 2013 Jitka Plesnikova <jplesnik@redhat.com> - 1.23-292
|
||||||
- Perl 5.18 re-rebuild of bootstrapped packages
|
- Perl 5.18 re-rebuild of bootstrapped packages
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue