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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
|
diff --git a/build/mt-dists/default.mk b/build/mt-dists/default.mk
index 06b910a..93c65d8 100644
@@ -1,8 +1,8 @@
PRODUCT_NAME = Movable Type Core
-PRODUCT_VERSION = 4.34
+PRODUCT_VERSION = 4.35
SCHEMA_VERSION = 4.0077
-API_VERSION = 4.34
+API_VERSION = 4.35
# BUILD_LANGUAGE = en_US
diff --git a/lib/MT/App/Search.pm b/lib/MT/App/Search.pm
index 124bea3..f7a9df1 100644
@@ -670,13 +670,14 @@ sub prepare_context {
$ctx->var('datebased_archive', 1) if ($app->param('archive_type') &&
( $app->param('archive_type') =~ /Daily/i || $app->param('archive_type') =~ /Weekly/i
|| $app->param('archive_type') =~ /Monthly/i || $app->param('archive_type') =~ /Yearly/i ));
- if ($app->param('author')) {
+ if ($app->param('author') && $app->param('author') =~ /^[0-9]*$/) {
require MT::Author;
- my $author = MT::Author->load($app->param('author'));
- $ctx->stash('author', $author);
- $ctx->var('author_archive', 1);
+ if ( my $author = MT::Author->load($app->param('author')) ) {
+ $ctx->stash('author', $author);
+ $ctx->var('author_archive', 1);
+ }
}
- if ($app->param('category')) {
+ if ($app->param('category') && $app->param('category') =~ /^[0-9]*$/) {
require MT::Category;
my $category = MT::Category->load($app->param('category'));
$ctx->stash('category', $category);
@@ -1004,6 +1005,8 @@ sub _join_category {
$query =~ s/'/"/g;
}
+ my $can_search_by_id = $query =~ /^[0-9]*$/ ? 1 : 0;
+
my $lucene_struct = Lucene::QueryParser::parse_query($query);
if ( 'PROHIBITED' eq $term->{type} ) {
$_->{type} = 'PROHIBITED' foreach @$lucene_struct;
@@ -1011,7 +1014,11 @@ sub _join_category {
# search for exact match
my ($terms)
- = $app->_query_parse_core( $lucene_struct, { id => 1, label => 1 }, {} );
+ = $app->_query_parse_core( $lucene_struct, {
+ ( $can_search_by_id ? ( id => 1 ) : () ),
+ label => 1
+ },
+ {} );
return unless $terms && @$terms;
push @$terms, '-and',
{
@@ -1039,12 +1046,17 @@ sub _join_author {
$query =~ s/'/"/g;
}
+ my $can_search_by_id = $query =~ /^[0-9]*$/ ? 1 : 0;
+
my $lucene_struct = Lucene::QueryParser::parse_query($query);
if ( 'PROHIBITED' eq $term->{type} ) {
$_->{type} = 'PROHIBITED' foreach @$lucene_struct;
}
my ($terms)
- = $app->_query_parse_core( $lucene_struct, { id => 1, nickname => 'like' },
+ = $app->_query_parse_core( $lucene_struct, {
+ ( $can_search_by_id ? ( id => 1 ) : () ),
+ nickname => 'like',
+ },
{} );
return unless $terms && @$terms;
push @$terms, '-and', { id => \'= entry_author_id', };
diff --git a/lib/MT/CMS/Tools.pm b/lib/MT/CMS/Tools.pm
index 45683da..607fc36 100644
@@ -112,6 +112,9 @@ sub start_recover {
$param ||= {};
$param->{'email'} = $app->param('email');
$param->{'return_to'} = $app->param('return_to') || $cfg->ReturnToURL || '';
+ if ( $param->{recovered} ) {
+ $param->{return_to} = MT::Util::encode_js($param->{return_to});
+ }
$param->{'can_signin'} = (ref $app eq 'MT::App::CMS') ? 1 : 0;
$app->add_breadcrumb( $app->translate('Password Recovery') );
@@ -298,7 +301,7 @@ sub new_password {
}
$app->make_commenter_session($user);
if ($redirect) {
- return $app->redirect($redirect);
+ return $app->redirect(MT::Util::encode_html($redirect));
} else {
return $app->redirect_to_edit_profile();
}
diff --git a/lib/MT/Template/Context/Search.pm b/lib/MT/Template/Context/Search.pm
index 4c7add2..0658bb2 100644
@@ -384,15 +384,15 @@ sub context_script {
$link .= "&type=$type";
}
if ( my $include_blogs = $ctx->stash('include_blogs') ) {
- $link .= "&IncludeBlogs=$include_blogs";
+ $link .= "&IncludeBlogs=" . encode_url($include_blogs);
}
elsif ( my $blog_id = $ctx->stash('blog_id') ) {
- $link .= "&blog_id=$blog_id";
+ $link .= "&blog_id=" . encode_url($blog_id);
}
if ( my $format = $ctx->stash('format') ) {
$link .= '&format=' . encode_url($format);
}
- $link;
+ $link;
}
1;
diff --git a/lib/MT/Template/ContextHandlers.pm b/lib/MT/Template/ContextHandlers.pm
index 49d17f2..355a3b1 100644
@@ -9037,6 +9037,8 @@ sub _hdlr_entry_flag {
my $flag = lc $args->{flag}
or return $ctx->error(MT->translate(
'You used <$MTEntryFlag$> without a flag.' ));
+ $e->has_column($flag)
+ or return $ctx->error(MT->translate("You have an error in your '[_2]' attribute: [_1]", $flag, 'flag'));
my $v = $e->$flag();
## The logic here: when we added the convert_breaks flag, we wanted it
## to default to checked, because we added it in 2.0, and people had
@@ -11422,7 +11424,8 @@ sub _hdlr_comment_reply_link {
return $ctx->_no_comment_error();
my $label = $args->{label} || $args->{text} || MT->translate('Reply');
- my $comment_author = MT::Util::encode_html( MT::Util::encode_js($comment->author) );
+ my $comment_author = MT::Util::encode_html(
+ MT::Util::encode_html( MT::Util::encode_js( $comment->author ) ), 1 );
my $onclick = sprintf( $args->{onclick} || "mtReplyCommentOnClick(%d, '%s')", $comment->id, $comment_author);
return sprintf(qq(<a title="%s" href="javascript:void(0);" onclick="$onclick">%s</a>),
@@ -16539,6 +16542,7 @@ sub _hdlr_assets {
AssetsHeader => !$i,
AssetsFooter => !defined $assets[$i+1],
});
+ return $ctx->error( $builder->errstr ) unless defined $out;
$res .= $out;
$row_count++;
$row_count = 0 if $row_count > $per_row;
@@ -17133,6 +17137,8 @@ sub _hdlr_asset_property {
} elsif ($prop =~ m/^image_/) {
$ret = 0;
} else {
+ $a->has_column($prop)
+ or return $ctx->error(MT->translate("You have an error in your '[_2]' attribute: [_1]", $prop, 'property'));
$ret = $a->$prop || '';
}
@@ -20051,17 +20057,17 @@ sub _hdlr_pager_link {
$link .= '?';
}
}
- $link .= "limit=$limit";
+ $link .= "limit=" . encode_url($limit);
#$link .= "&offset=$offset" if $offset;
- $link .= "&category=$category" if $category;
- $link .= "&author=$author" if $author;
- $link .= "&page=$page" if $page;
- $link .= "&year=$year" if $year;
- $link .= "&month=$month" if $month;
- $link .= "&day=$day" if $day;
- $link .= "&archive_type=$archive_type" if $archive_type;
- $link .= "&template_id=$template_id" if $template_id;
+ $link .= "&category=" . encode_url($category) if $category;
+ $link .= "&author=" . encode_url($author) if $author;
+ $link .= "&page=" . encode_url($page) if $page;
+ $link .= "&year=" . encode_url($year) if $year;
+ $link .= "&month=" . encode_url($month) if $month;
+ $link .= "&day=" . encode_url($day) if $day;
+ $link .= "&archive_type=" . encode_url($archive_type) if $archive_type;
+ $link .= "&template_id=" . encode_url($template_id) if $template_id;
return $link;
}
diff --git a/php/extlib/ezsql/ezsql_postgres.php b/php/extlib/ezsql/ezsql_postgres.php
index df33a17..8276293 100644
@@ -160,7 +160,7 @@
// try to find table name
- eregi ("insert *into *([^ ]+).*", $query, $regs);
+ preg_match ("/insert *into *([^ ]+).*/i", $query, $regs);
//print_r($regs);
diff --git a/php/lib/mtdb_base.php b/php/lib/mtdb_base.php
index 9d459bb..63520c8 100644
@@ -56,7 +56,8 @@ class MTDatabaseBase extends ezsql {
function unserialize($data) {
if (!$this->serializer) {
require_once("MTSerialize.php");
- $this->serializer =& new MTSerialize();
+ $serializer = new MTSerialize();
+ $this->serializer =& $serializer;
}
return $this->serializer->unserialize($data);
}
@@ -66,9 +67,8 @@ class MTDatabaseBase extends ezsql {
parent::query($query);
}
- function &resolve_url($path, $blog_id) {
+ function &resolve_url($path, $blog_id, $build_type = 3) {
$path = preg_replace('!/$!', '', $path);
- $path = $this->escape($path);
$blog_id = intval($blog_id);
# resolve for $path -- one of:
# /path/to/file.html
@@ -90,7 +90,7 @@ class MTDatabaseBase extends ezsql {
and template_type != 'backup'
order by length(fileinfo_url) asc
";
- $rows = $this->get_results(sprintf($sql,$p), ARRAY_A);
+ $rows = $this->get_results(sprintf($sql,$this->escape($p)), ARRAY_A);
if ($rows) {
break;
}
@@ -100,6 +100,21 @@ class MTDatabaseBase extends ezsql {
$found = false;
foreach ($rows as $row) {
+ if ( !empty( $build_type ) ) {
+ if ( !is_array( $build_type ) ) {
+ $build_type_array = array( $build_type );
+ } else {
+ $build_type_array = $build_type;
+ }
+
+ $type = isset($row['templatemap_build_type']) && strlen($row['templatemap_build_type']) > 0
+ ? $row['templatemap_build_type'] : $row['template_build_type'];
+
+ if ( !in_array( $type, $build_type_array ) ) {
+ continue;
+ }
+ }
+
$fiurl = $row['fileinfo_url'];
if ($fiurl == $path) {
$found = true;
diff --git a/php/mt.php.pre b/php/mt.php.pre
index 1d91e34..c98d56e 100644
@@ -200,7 +200,7 @@ class MT {
if ($fp = file($file)) {
foreach ($fp as $line) {
// search through the file
- if (!ereg('^\s*\#',$line)) {
+ if (!preg_match('/^\s*\#/',$line)) {
// ignore lines starting with the hash symbol
if (preg_match('/^\s*(\S+)\s+(.*)$/', $line, $regs)) {
$key = strtolower(trim($regs[1]));
@@ -291,7 +291,7 @@ class MT {
$data = preg_split('/[\r?\n]/', $data);
foreach ($data as $line) {
// search through the file
- if (!ereg('^\s*\#',$line)) {
+ if (!preg_match('/^\s*\#/',$line)) {
// ignore lines starting with the hash symbol
if (preg_match('/^\s*(\S+)\s+(.*)$/', $line, $regs)) {
$key = strtolower(trim($regs[1]));
@@ -454,6 +454,7 @@ class MT {
}
// now set the path so it may be queried
+ $path = preg_replace('/\\\\/', '\\\\\\\\', $path );
$this->request = $path;
// When we are invoked as an ErrorDocument, the parameters are
|