734417
From 1735f6f53ca19f99c6e9e39496c486af323ba6a8 Mon Sep 17 00:00:00 2001
734417
From: Brian Carlson <brian.carlson@cpanel.net>
734417
Date: Wed, 28 Nov 2012 08:54:33 -0500
734417
Subject: [PATCH] Fix misparsing of maketext strings.
734417
734417
Case 61251: This commit fixes a misparse of maketext strings that could
734417
lead to arbitrary code execution.  Basically, maketext was compiling
734417
bracket notation into functions, but neglected to escape backslashes
734417
inside the content or die on fully-qualified method names when
734417
generating the code.  This change escapes all such backslashes and dies
734417
when a method name with a colon or apostrophe is specified.
734417
---
734417
 AUTHORS                                     |  1 +
734417
 dist/Locale-Maketext/lib/Locale/Maketext.pm | 24 ++++++++----------------
734417
 2 files changed, 9 insertions(+), 16 deletions(-)
734417
734417
diff --git a/AUTHORS b/AUTHORS
734417
index 70734b0..009dea0 100644
734417
--- a/AUTHORS
734417
+++ b/AUTHORS
734417
@@ -154,6 +154,7 @@ Breno G. de Oliveira		<garu@cpan.org>
734417
 Brent Dax			<brentdax@cpan.org>
734417
 Brooks D Boyd
734417
 Brian Callaghan			<callagh@itginc.com>
734417
+Brian Carlson			<brian.carlson@cpanel.net>
734417
 Brian Clarke			<clarke@appliedmeta.com>
734417
 brian d foy			<brian.d.foy@gmail.com>
734417
 Brian Fraser			<fraserbn@gmail.com>
734417
diff --git a/dist/Locale-Maketext/lib/Locale/Maketext.pm b/dist/Locale-Maketext/lib/Locale/Maketext.pm
734417
index 4822027..63e5fba 100644
734417
--- a/dist/Locale-Maketext/lib/Locale/Maketext.pm
734417
+++ b/dist/Locale-Maketext/lib/Locale/Maketext.pm
734417
@@ -625,21 +625,9 @@ sub _compile {
734417
                         # 0-length method name means to just interpolate:
734417
                         push @code, ' (';
734417
                     }
734417
-                    elsif($m =~ /^\w+(?:\:\:\w+)*$/s
734417
-                            and $m !~ m/(?:^|\:)\d/s
734417
-                        # exclude starting a (sub)package or symbol with a digit
734417
+                    elsif($m =~ /^\w+$/s
734417
+                        # exclude anything fancy, especially fully-qualified module names
734417
                     ) {
734417
-                        # Yes, it even supports the demented (and undocumented?)
734417
-                        #  $obj->Foo::bar(...) syntax.
734417
-                        $target->_die_pointing(
734417
-                            $string_to_compile, q{Can't use "SUPER::" in a bracket-group method},
734417
-                            2 + length($c[-1])
734417
-                        )
734417
-                        if $m =~ m/^SUPER::/s;
734417
-                        # Because for SUPER:: to work, we'd have to compile this into
734417
-                        #  the right package, and that seems just not worth the bother,
734417
-                        #  unless someone convinces me otherwise.
734417
-
734417
                         push @code, ' $_[0]->' . $m . '(';
734417
                     }
734417
                     else {
734417
@@ -693,7 +681,9 @@ sub _compile {
734417
             elsif(substr($1,0,1) ne '~') {
734417
                 # it's stuff not containing "~" or "[" or "]"
734417
                 # i.e., a literal blob
734417
-                $c[-1] .= $1;
734417
+                my $text = $1;
734417
+                $text =~ s/\\/\\\\/g;
734417
+                $c[-1] .= $text;
734417
 
734417
             }
734417
             elsif($1 eq '~~') { # "~~"
734417
@@ -731,7 +721,9 @@ sub _compile {
734417
             else {
734417
                 # It's a "~X" where X is not a special character.
734417
                 # Consider it a literal ~ and X.
734417
-                $c[-1] .= $1;
734417
+                my $text = $1;
734417
+                $text =~ s/\\/\\\\/g;
734417
+                $c[-1] .= $text;
734417
             }
734417
         }
734417
     }
734417
-- 
734417
1.7.11.7
734417