--- lib/MT/Util.pm.orig 2008-03-11 16:14:38.000000000 -0500
+++ lib/MT/Util.pm 2008-03-11 16:35:49.000000000 -0500
@@ -461,7 +461,17 @@
$html =~ s!>!>!g;
}
#Encode::_utf8_off($html) if MT->instance->charset eq 'utf-8';
- $html;
+ return strip_chars($html);
+ }
+
+ sub strip_chars {
+ my ($string) = @_;
+ if (MT->instance->charset eq 'utf-8') {
+ $string =~ s/[^\x09\x0A\x0D\x20-\x{D7FF}\x{E000}-\x{FFFD}\x{10000}-\x{10FFFF}]/\x{FFFD}/g;
+ } else {
+ $string =~ s/[\x00-\x08\x0B\x0C\x0E\x0F\x10-\x1F\x80-\x9F]//g;
+ }
+ return $string;
}
sub decode_html {
--- lib/MT/Sanitize.pm.orig 2007-01-05 18:29:17.000000000 -0600
+++ lib/MT/Sanitize.pm 2007-04-17 02:26:58.000000000 -0500
@@ -22,7 +22,7 @@
my(%ok_tags, %tag_attr);
for my $rule (split /\s*,\s*/, $a) {
my(%ok_attr, $tag, $style);
- $tag = lc $rule;
+ $tag = $rule;
if ($tag =~ m|^([^\s]+)\s+(.+)$|) {
($tag, my($attrs)) = ($1, $2);
$style = $1 if $tag =~ s|(/)$||;
@@ -84,10 +84,10 @@
my $name;
my $closure = 0;
if ($inside =~ m/^([^ ]+) (.+)$/s) {
- $name = lc($1);
+ $name = $1;
$inside = $2;
} else {
- $name = lc($inside);
+ $name = $inside;
$inside = '';
}
if ($name =~ m|^/|) {
@@ -102,8 +102,8 @@
(exists $tag_attr->{$name} && $tag_attr->{$name} eq '/')) {
if ($inside) {
my @attrs;
- while ($inside =~ m/([:\w]+)\s*=\s*(['"])(.*?)\2/gs) {
- my ($attr, $q, $val) = (lc($1), $2, $3);
+ while ($inside =~ m/([\-:\w]+)\s*=\s*(['"])(.*?)\2/gs) {
+ my ($attr, $q, $val) = ($1, $2, $3);
if ($ok_tags->{'*'}{$attr} ||
(ref $ok_tags->{$name} && $ok_tags->{$name}{$attr})) {
my $dec_val = decode_html($val);
@@ -114,7 +114,7 @@
if ((my $prot) = $dec_val =~ m/^(.+?):/) {
next if $prot =~ m/[\r\n\t]/;
$prot =~ s/\s+//gs;
- next if $prot =~ m/[^a-zA-Z0-9\+]/;
+ next if $prot =~ m/[^a-zA-Z0-9\+#]/;
next if $prot =~ m/script$/i;
next if $prot =~ m//;
}
--- lib/MT/Blog.pm.orig 2006-07-17 23:39:38.000000000 -0500
+++ lib/MT/Blog.pm 2006-07-17 23:44:53.000000000 -0500
@@ -55,7 +55,7 @@
'ping_technorati' => 'boolean',
'ping_others' => 'text',
'autodiscover_links' => 'boolean',
- 'sanitize_spec' => 'string(255)',
+ 'sanitize_spec' => 'text',
'cc_license' => 'string(255)',
'is_dynamic' => 'boolean',
'remote_auth_token' => 'string(50)',
--- lib/MT/App.pm.orig 2007-01-23 17:52:24.000000000 -0600
+++ lib/MT/App.pm 2008-03-11 18:36:28.000000000 -0500
@@ -101,6 +101,9 @@
sub send_http_header {
my $app = shift;
my($type) = @_;
+ if ($ENV{'HTTP_CONTENT_TYPE'} && $ENV{'HTTP_CONTENT_TYPE'} ne '' ){
+ $type= $ENV{'HTTP_CONTENT_TYPE'};
+ }
$type ||= 'text/html';
if (my $charset = $app->charset) {
$type .= "; charset=$charset"
@@ -581,9 +584,9 @@
if ($MT::DebugMode && $@) {
$error = '
'.encode_html($error).'
';
} else {
- $error = encode_html($error);
+ $error = encode_html($error,1);
}
- $error =~ s!(http://\S+)!$1!g;
+ $error =~ s!(http://\S+)!$1!g;
$tmpl = $app->load_tmpl('error.tmpl') or
return "Can't load error template; got error '" . $app->errstr .
"'. Giving up. Original error was $error
";
--- tmpl/email/new-comment.tmpl.orig 2006-06-24 00:54:07.000000000 -0500
+++ tmpl/email/new-comment.tmpl 2006-07-03 08:17:18.000000000 -0500
@@ -9,6 +9,7 @@
:
:
:
+
--- lib/MT/Comment.pm.orig 2006-06-16 04:09:55.000000000 -0500
+++ lib/MT/Comment.pm 2006-06-25 00:39:09.000000000 -0500
@@ -21,6 +21,9 @@
'email' => 'string(75)',
'url' => 'string(255)',
'text' => 'text',
+ 'subject' => 'text',
+ 'parent_id' => 'integer not null',
+ 'convert_breaks' => 'string(30)',
'ip' => 'string(16)',
'last_moved_on' => 'datetime not null',
'junk_score' => 'float',
@@ -31,6 +34,7 @@
created_on => 1,
entry_id => 1,
blog_id => 1,
+ parent_id => 1,
email => 1,
commenter_id => 1,
visible => 1,
--- lib/MT/App/Search.pm.orig 2007-01-23 17:52:24.000000000 -0600
+++ lib/MT/App/Search.pm 2008-03-12 10:19:16.000000000 -0500
@@ -165,6 +165,12 @@
my $file = File::Spec->catfile($app->config('TempDir'), 'mt-throttle.db');
my $DB = tie my %db, 'DB_File', $file;
if ($DB) {
+ #throttle total number of searches
+ my $max_searches = 5;
+ if (scalar(keys %db) > $max_searches ) {
+ return $app->error($app->translate(
+ "Too many searches are ongoing. Please try yours again later."));
+ }
if (my $time = $db{$ip}) {
if ($time > time - $app->config('ThrottleSeconds')) {
return 0;
@@ -187,7 +193,7 @@
'mt-throttle.db');
if (tie my %db, 'DB_File', $file) {
my $time = $db{$app->remote_ip};
- delete $db{$app->remote_ip} if ($time && $time < (time - $app->config('ThrottleSeconds')));
+ delete $db{$app->remote_ip};
untie %db;
}
}
@@ -450,7 +456,7 @@
require MT::Log;
$app->log({
- message => $app->translate("Search: query for '[_1]'",
+ message => $app->translate(encode_html("Search: query for '[_1]'",1),
$app->{search_string}),
level => MT::Log::INFO(),
class => 'search',
--- lib/MT/TBPing.pm.orig 2006-06-27 15:58:14.000000000 -0500
+++ lib/MT/TBPing.pm 2006-07-03 08:22:44.000000000 -0500
@@ -23,6 +23,7 @@
'source_url' => 'string(255)',
'ip' => 'string(15) not null',
'blog_name' => 'string(255)',
+ 'tb_charset' => 'string(255)',
'visible' => 'boolean',
'junk_status' => 'smallint not null',
'last_moved_on' => 'datetime not null',
--- lib/MT/App/Trackback.pm.orig 2007-01-23 17:52:24.000000000 -0600
+++ lib/MT/App/Trackback.pm 2007-04-18 02:03:46.000000000 -0500
@@ -129,7 +129,7 @@
return 0;
}
- @ts = offset_time_list(time - $app->config('ThrottleSeconds')*4000 - 1,
+ @ts = offset_time_list(time - 86400,
$tb->blog_id);
$from = sprintf("%04d%02d%02d%02d%02d%02d",
$ts[5]+1900, $ts[4]+1, @ts[3,2,1,0]);
@@ -209,10 +209,10 @@
}
}
- no_utf8($tb_id, $title, $excerpt, $url, $blog_name);
+ #no_utf8($tb_id, $title, $excerpt, $url, $blog_name);
# guess encoding as possible
- $enc = MT::I18N::guess_encoding($excerpt.$title.$blog_name) unless $enc;
- ($title, $excerpt, $blog_name) = map { encode_text($_, $enc) } ($title, $excerpt, $blog_name);
+# $enc = MT::I18N::guess_encoding($excerpt.$title.$blog_name) unless $enc;
+# ($title, $excerpt, $blog_name) = map { encode_text($_, $enc) } ($title, $excerpt, $blog_name);
return $app->_response(Error=> $app->translate("Need a Source URL (url)."))
unless $url;
@@ -261,6 +261,9 @@
$ping->tb_id($tb_id);
$ping->source_url($url);
$ping->ip($app->remote_ip || '');
+ if ($ENV{'CONTENT_TYPE'} =~ /[Cc]harset=([a-zA-Z0-9-]+)/) {
+ $ping->tb_charset($1);
+ }
$ping->junk_status(0);
$ping->visible(1);
}
@@ -285,6 +288,29 @@
$ping->column($field, $val);
}
}
+ ## BEGIN HACK Avoid Duplicate Trackback Pings
+ ## http://www.nonplus.net/software/mt/AvoidingDuplicateTrackbackPings.htm
+ my $duplicate_ping = 0;
+ if(my @existing_pings = MT::TBPing->load({
+ blog_id => $ping->blog_id,
+ tb_id => $ping->tb_id })) {
+ foreach my $p (@existing_pings) {
+ next unless ($p->source_url eq $ping->source_url && $p->ip eq $ping->ip);
+ # If everything is the same, simply return
+ return $app->_response if ( ($p->title eq $ping->title)
+ && ($p->blog_name eq $ping->blog_name)
+ && ($p->excerpt eq $ping->excerpt));
+ # If something is different, copy new values to old ping
+ $p->title($ping->title);
+ $p->blog_name($ping->blog_name);
+ $p->excerpt($ping->excerpt);
+ # and replace new ping with old ping
+ $ping = $p;
+ $duplicate_ping = 1;
+ last;
+ }
+ }
+ ## END HACK Avoid Duplicate Trackback Pings
if (!MT->run_callbacks('TBPingFilter', $app, $ping)) {
return $app->_response(Error => "", Code => 403);
@@ -353,7 +379,7 @@
$app->translate("Can't create RSS feed '[_1]': ", $feed,
$fmgr->errstr));
}
- $app->_send_ping_notification($blog, $entry, $cat, $ping);
+ $app->_send_ping_notification($blog, $entry, $cat, $ping) unless $duplicate_ping ;
});
}
} else {
@@ -435,11 +461,12 @@
sub rss {
my $app = shift;
my($tb_id, $pass) = $app->_get_params;
- my $tb = MT::Trackback->load($tb_id)
- or return $app->_response(Error =>
- $app->translate("Invalid TrackBack ID '[_1]'", $tb_id));
- my $rss = _generate_rss($tb);
- $app->_response(RSS => $rss);
+# my $tb = MT::Trackback->load($tb_id) or
+ return $app->_response(Error =>
+ $app->translate("RSS disabled because of Trackback Spam"));
+# $app->translate("Invalid TrackBack ID '[_1]'", $tb_id));
+# my $rss = _generate_rss($tb);
+# $app->_response(RSS => $rss);
}
sub _generate_rss {
--- lib/MT/App/Comments.pm.orig 2006-08-03 16:15:31.000000000 -0500
+++ lib/MT/App/Comments.pm 2006-09-04 01:49:27.000000000 -0500
@@ -114,9 +114,11 @@
unless ($comment->visible);
my $uri = encode_html($comment->url);
return <
-Redirecting...
-
+
+
+
+Redirecting...
+
@@ -264,6 +266,33 @@
if ($text eq '') {
return $app->handle_error($app->translate("Comment text is required."));
}
+ require Digest::SHA1;
+ my $sha1 = Digest::SHA1->new;
+
+ $sha1->add($q->param('text') . $q->param('entry_id') . $app->remote_ip
+ . $q->param('author') . $q->param('email') . $q->param('url')
+ . $q->param('subject') . $q->param('convert_breaks'));
+ my $salt_file = MT::ConfigMgr->instance->PluginPath .'/salt.txt';
+ my $FH;
+ open($FH, $salt_file) or die "cannot open file <$salt_file> ($!)";
+ $sha1->addfile($FH);
+ close $FH;
+
+ my $digest = $sha1->b64digest . "=";
+
+ if (!$q->param('validated') ) {
+ my $ban = MT::IPBanList->new;
+ $ban->blog_id($entry->blog_id);
+ $ban->ip($app->remote_ip);
+ $ban->save
+ or die $ban->errstr;
+ return $app->handle_error($app->translate("You are not allowed to post comments."));
+ }
+
+ if ($q->param('validated') ne $digest) {
+ return $app->handle_error($app->translate(
+ "Please preview your modified entry before posting it."));
+ }
my ($comment, $commenter) = _make_comment($app, $entry);
my $remember = $q->param('bakecookie') || 0;
@@ -509,6 +538,7 @@
$email = $commenter->email();
}
my $url = $q->param('url') || ''; #($commenter ? $commenter->url() : '');
+ my $subject = $q->param('subject') ? $q->param('subject') : ' ';
my $comment = MT::Comment->new;
if ($commenter) {
$comment->commenter_id($commenter->id);
@@ -516,7 +546,7 @@
## Strip linefeed characters.
my $text = $q->param('text');
$text = '' unless defined $text;
- $text =~ tr/\r//d;
+# $text =~ tr/\r//d;
$comment->ip($app->remote_ip);
$comment->blog_id($entry->blog_id);
$comment->entry_id($entry->id);
@@ -524,6 +554,9 @@
$comment->email(remove_html($email));
$comment->url(is_valid_url($url, 'stringent'));
$comment->text($text);
+ $comment->subject($subject);
+ $comment->parent_id($q->param('parent_id'));
+ $comment->convert_breaks($q->param('convert_breaks'));
#$comment->visible(0); # leave as undefined
$comment->is_junk(0);
@@ -608,6 +641,7 @@
(comment_email => $comment->email):()),
comment_url => $comment->url,
comment_text => wrap_text($comment->text, 72),
+ comment_subject => $comment->subject,
unapproved => !$comment->visible(),
);
my $body = MT->build_email('new-comment.tmpl', \%param);
@@ -1015,6 +1049,8 @@
$ctx->stash('entry', $entry);
$ctx->stash('commenter', $cmntr) if ($cmntr);
$ctx->{current_timestamp} = $entry->created_on;
+ $ctx->stash('comment_parent_id', $q->param('parent_id'));
+ $ctx->stash('convert_breaks', $q->param('convert_breaks'));
my %cond;
my $tmpl = ($q->param('arch')) ?
(MT::Template->load({ type => 'individual',
--- lib/MT/Template/ContextHandlers.pm.orig 2006-07-06 12:11:02.000000000 -0500
+++ lib/MT/Template/ContextHandlers.pm 2006-08-17 21:34:47.000000000 -0500
@@ -22,6 +22,8 @@
use MT::Entry;
use MT::I18N qw( first_n_text const );
+my $publish_charset = _hdlr_publish_charset();
+
sub init_default_handlers {
%MT::Template::Context::Handlers = (
Else => [ \&_hdlr_pass_tokens, 1 ],
@@ -2553,11 +2555,14 @@
unless ($blog->allow_comment_html) {
$t = remove_html($t);
}
+ my $filter = defined $c->convert_breaks ?
+ [$c->convert_breaks] :
+ $blog->comment_text_filters;
my $convert_breaks = exists $arg->{convert_breaks} ?
$arg->{convert_breaks} :
$blog->convert_paras_comments;
$t = $convert_breaks ?
- MT->apply_text_filters($t, $blog->comment_text_filters, $ctx) :
+ MT->apply_text_filters($t, $filter, $ctx) :
$t;
if (!(exists $arg->{autolink} && !$arg->{autolink}) &&
$blog->autolink_urls) {
@@ -3594,7 +3599,8 @@
sanitize_on($_[1]);
my $ping = $_[0]->stash('ping')
or return $_[0]->_no_ping_error('MTPingTitle');
- defined $ping->title ? $ping->title : '';
+ my $title = defined $ping->title ? $ping->title : '';
+ return _transcode_text($ping->tb_charset, $title);
}
sub _hdlr_ping_url {
sanitize_on($_[1]);
@@ -3606,7 +3612,8 @@
sanitize_on($_[1]);
my $ping = $_[0]->stash('ping')
or return $_[0]->_no_ping_error('MTPingExcerpt');
- defined $ping->excerpt ? $ping->excerpt : '';
+ my $excerpt = defined $ping->excerpt ? $ping->excerpt : '';
+ return _transcode_text($ping->tb_charset, $excerpt);
}
sub _hdlr_ping_ip {
my $ping = $_[0]->stash('ping')
@@ -3617,7 +3624,21 @@
sanitize_on($_[1]);
my $ping = $_[0]->stash('ping')
or return $_[0]->_no_ping_error('MTPingBlogName');
- defined $ping->blog_name ? $ping->blog_name : '';
+ my $blog_name = defined $ping->blog_name ? $ping->blog_name : '';
+ return _transcode_text($ping->tb_charset, $blog_name);
+}
+
+sub _transcode_text {
+ my ($text_charset, $text) = @_;
+ require Text::Iconv;
+ use Encode;
+ if (defined $text_charset && lc($text_charset) ne $publish_charset ) {
+ $text_charset = lc($text_charset);
+ $text = Text::Iconv->new($text_charset,'utf-8')->convert($text) unless $text_charset eq 'utf-8';
+ $text = encode($publish_charset, decode('utf-8',$text), Encode::FB_XMLCREF) unless $publish_charset eq 'utf-8';
+ }
+ $text =~ s/&(?!#?[xX]?(?:[0-9a-fA-F]+|\w+);)/&/g;
+ return $text;
}
sub _hdlr_if_allow_comment_html {
--- tmpl/cms/header-popup.tmpl.orig 2006-06-13 19:15:36.000000000 -0500
+++ tmpl/cms/header-popup.tmpl 2006-07-03 14:25:06.000000000 -0500
@@ -1,6 +1,6 @@
-
+
|
--- tmpl/cms/header.tmpl.orig 2006-06-24 00:54:07.000000000 -0500
+++ tmpl/cms/header.tmpl 2006-07-03 14:29:26.000000000 -0500
@@ -1,6 +1,7 @@
-
+
+
-
+
|
--- tmpl/cms/list_comment.tmpl.orig 2006-06-24 00:54:07.000000000 -0500
+++ tmpl/cms/list_comment.tmpl 2006-07-03 14:34:54.000000000 -0500
@@ -1,7 +1,7 @@