File: maketext-format-string-sec

package info (click to toggle)
movabletype-opensource 5.1.4%2Bdfsg-4%2Bdeb7u3
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 32,996 kB
  • sloc: perl: 197,285; php: 62,405; sh: 166; xml: 117; makefile: 83; sql: 32
file content (68 lines) | stat: -rw-r--r-- 1,924 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
diff --git a/lib/MT/App/Wizard.pm b/lib/MT/App/Wizard.pm
index 1847507..f14b141 100644
--- a/lib/MT/App/Wizard.pm
+++ b/lib/MT/App/Wizard.pm
@@ -89,9 +89,9 @@ sub init_request {
         $app->delete_param('test') if $app->param('test');
     }
 
-    # If mt-check.cgi exists, redirect to errro screen
+    # If mt-config.cgi exists, redirect to error screen
     my $cfg_exists = $app->is_config_exists();
-    if ( $cfg_exists && lc $step ne 'seed' && lc $mode ne 'retry' ) {
+    if ( $cfg_exists && lc $step ne 'seed' ) {
         my %param;
         $param{cfg_exists} = 1;
         $app->mode('pre_start');
diff --git a/lib/MT/L10N.pm b/lib/MT/L10N.pm
index 2d2bbd2..04bb1e5 100644
--- a/lib/MT/L10N.pm
+++ b/lib/MT/L10N.pm
@@ -11,6 +11,8 @@ use Locale::Maketext;
 @MT::L10N::ISA = qw( Locale::Maketext );
 @MT::L10N::Lexicon = ( _AUTO => 1, );
 
+our $PERMITTED_METHODS_REGEX = qr/^(?:lc|uc|quant|numerate|numf|sprintf)$/;
+
 sub language_name {
     my $tag = $_[0]->language_tag;
     require I18N::LangTags::List;
@@ -30,12 +32,26 @@ sub uc {
     uc( $_[0] );
 }
 
+# Restrict enabled methods in bracket.
+sub _compile {
+    my ( $lh, $string ) = @_;
+
+    if ( $string
+        && grep { $_ !~ m/$PERMITTED_METHODS_REGEX/ && $_ !~ m/^_-?\d+$/ }
+        ( $string =~ m/(?:^|[^~])(?:~~)*\[(\w+)(?:,|\])/gs ) )
+    {
+        die 'Invalid method in translating phrase: "' . $string . '"';
+    }
+
+    return $lh->SUPER::_compile($string);
+}
+
 1;
 __END__
 
 =head1 NAME
 
-MT::L10N
+MT::L10N - Localization support for MT
 
 =head1 METHODS
 
@@ -51,6 +67,10 @@ Return 'iso-8859-1' (Latin-1).
 
 Return zero.
 
+=head2 $obj->_compile($str)
+
+Override Locale::Maketext::_compile. Non-permitted methods but underscore and numbers like "_1" in bracket notation are forbidden here. Permitted methods are defined by $PERMITTED_METHODS_REGEX.
+
 =head1 AUTHOR & COPYRIGHT
 
 Please see L<MT/AUTHOR & COPYRIGHT>.