|
|
432ff7 |
From b130af4d27aa7d29f2af2b61296abc1bb6ae6d66 Mon Sep 17 00:00:00 2001
|
|
|
432ff7 |
From: =?UTF-8?q?=3D=3FUTF-8=3Fq=3FPetr=3D20P=3DC3=3DADsa=3DC5=3D99=3F=3D?=
|
|
|
432ff7 |
<ppisar@redhat.com>
|
|
|
432ff7 |
Date: Fri, 8 Nov 2013 02:17:08 +0100
|
|
|
432ff7 |
Subject: [PATCH] Commit 1735f6f53ca19f99c6e9e39496c486af323ba6a8 started to
|
|
|
432ff7 |
escape all back-slashes which breaks case when lexicon translations contain
|
|
|
432ff7 |
substition and literals with eval-non-safe characters. E.g. these
|
|
|
432ff7 |
translations:
|
|
|
432ff7 |
MIME-Version: 1.0
|
|
|
432ff7 |
Content-Type: text/plain; charset=UTF-8
|
|
|
432ff7 |
Content-Transfer-Encoding: 8bit
|
|
|
432ff7 |
|
|
|
432ff7 |
"[_1]foo\\n\n" => "[_1]bar\\n\n",
|
|
|
432ff7 |
'[_1]foo\n' => '[_1]aÄa\n',
|
|
|
432ff7 |
|
|
|
432ff7 |
got doubled back-slashes on the maketext() output.
|
|
|
432ff7 |
|
|
|
432ff7 |
This patch de-escapes escaped backslashes if the literal is compiled as
|
|
|
432ff7 |
function argument.
|
|
|
432ff7 |
|
|
|
432ff7 |
Fixes RT #120457.
|
|
|
432ff7 |
|
|
|
432ff7 |
Signed-off-by: Petr Písař <ppisar@redhat.com>
|
|
|
432ff7 |
---
|
|
|
432ff7 |
MANIFEST | 1 +
|
|
|
432ff7 |
lib/Locale/Maketext.pm | 1 +
|
|
|
432ff7 |
t/91_backslash.t | 33 +++++++++++++++++++++++++++++++++
|
|
|
432ff7 |
3 files changed, 35 insertions(+)
|
|
|
432ff7 |
create mode 100644 t/91_backslash.t
|
|
|
432ff7 |
|
|
|
432ff7 |
diff --git a/MANIFEST b/MANIFEST
|
|
|
432ff7 |
index 32c65ba..b409558 100644
|
|
|
432ff7 |
--- a/MANIFEST
|
|
|
432ff7 |
+++ b/MANIFEST
|
|
|
432ff7 |
@@ -23,5 +23,6 @@ t/50_super.t
|
|
|
432ff7 |
t/60_super.t
|
|
|
432ff7 |
t/70_fail_auto.t
|
|
|
432ff7 |
t/90_utf8.t
|
|
|
432ff7 |
+t/91_backslash.t See if Locale::Maketext works
|
|
|
432ff7 |
t/pod.t
|
|
|
432ff7 |
META.json Module JSON meta-data (added by MakeMaker)
|
|
|
432ff7 |
diff --git a/lib/Locale/Maketext.pm b/lib/Locale/Maketext.pm
|
|
|
432ff7 |
index 63e5fba..26efc94 100644
|
|
|
432ff7 |
--- a/lib/Locale/Maketext.pm
|
|
|
432ff7 |
+++ b/lib/Locale/Maketext.pm
|
|
|
432ff7 |
@@ -570,6 +570,7 @@ sub _compile {
|
|
|
432ff7 |
$c[-1] = ''; # reuse this slot
|
|
|
432ff7 |
}
|
|
|
432ff7 |
else {
|
|
|
432ff7 |
+ $c[-1] =~ s/\\\\/\\/g;
|
|
|
432ff7 |
push @code, ' $c[' . $#c . "],\n";
|
|
|
432ff7 |
push @c, ''; # new chunk
|
|
|
432ff7 |
}
|
|
|
432ff7 |
diff --git a/t/91_backslash.t b/t/91_backslash.t
|
|
|
432ff7 |
new file mode 100644
|
|
|
432ff7 |
index 0000000..f96edd1
|
|
|
432ff7 |
--- /dev/null
|
|
|
432ff7 |
+++ b/t/91_backslash.t
|
|
|
432ff7 |
@@ -0,0 +1,33 @@
|
|
|
432ff7 |
+#!/usr/bin/perl -Tw
|
|
|
432ff7 |
+
|
|
|
432ff7 |
+use strict;
|
|
|
432ff7 |
+use Test::More tests => 6;
|
|
|
432ff7 |
+
|
|
|
432ff7 |
+BEGIN {
|
|
|
432ff7 |
+ use_ok( 'Locale::Maketext' );
|
|
|
432ff7 |
+}
|
|
|
432ff7 |
+
|
|
|
432ff7 |
+use utf8;
|
|
|
432ff7 |
+
|
|
|
432ff7 |
+{
|
|
|
432ff7 |
+ package My::Localize;
|
|
|
432ff7 |
+ our @ISA = ('Locale::Maketext');
|
|
|
432ff7 |
+}
|
|
|
432ff7 |
+{
|
|
|
432ff7 |
+ package My::Localize::cs_cz;
|
|
|
432ff7 |
+ our @ISA = ('My::Localize');
|
|
|
432ff7 |
+ our %Lexicon = (
|
|
|
432ff7 |
+ '[_1]foo1\n' => '[_1]bar\n',
|
|
|
432ff7 |
+ '[_1]foo2\n' => '[_1]běr\n',
|
|
|
432ff7 |
+ 'foo2\n' => 'aěa\n',
|
|
|
432ff7 |
+ "[_1]foo\\n\n" => "[_1]bar\\n\n",
|
|
|
432ff7 |
+ );
|
|
|
432ff7 |
+ keys %Lexicon; # dodges the 'used only once' warning
|
|
|
432ff7 |
+}
|
|
|
432ff7 |
+
|
|
|
432ff7 |
+my $lh = My::Localize->get_handle('cs_cz');
|
|
|
432ff7 |
+isa_ok( $lh, 'My::Localize::cs_cz' );
|
|
|
432ff7 |
+is( $lh->maketext('[_1]foo1\n', 'arg'), 'argbar\n', 'Safe parameterized' );
|
|
|
432ff7 |
+is( $lh->maketext('[_1]foo2\n', 'arg'), 'argběr\n', 'Unicode parameterized' );
|
|
|
432ff7 |
+is( $lh->maketext('foo2\n'), 'aěa\n', 'Unicode literal' );
|
|
|
432ff7 |
+is( $lh->maketext("[_1]foo\\n\n", 'arg'), "argbar\\n\n", 'new line parameterized' );
|
|
|
432ff7 |
--
|
|
|
432ff7 |
1.8.3.1
|
|
|
432ff7 |
|