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