$allowed = $c->app->config->{Editor}->{allowed_tags};
}
else {
+ $c->app->log->warn("NewslashHelper::_format_htmltext: invalid type - '$type'");
$allowed = $c->app->config->{Editor}->{allowed_tags};
}
return Newslash::Util::TextFormatter::escape_html($allowed, $text);
my $data = $c->req->json;
my $message = "";
- $params->{title} = $c->escape_title($data->{title});
+ $params->{title} = $c->format_htmltext($data->{title}, "title");
$params->{comment} = $c->format_htmltext($data->{comment}, "comment");
$params->{discussion_id} = $data->{discussion_id};
$params->{stoid} = $data->{stoid};
my $item = $data->{item};
my $message = "";
- $params->{description} = $c->escape_title($item->{title});
+ $params->{description} = $c->format_htmltext($item->{title}, "text");
$message = "no title!" if !$params->{description};
# check user is valid
$message = "no_content" if (!$params->{introtext} && !$item->{url});
# check title
- $params->{title} = $c->escape_title($item->{title});
+ $params->{title} = $c->format_htmltext($item->{title}, "title");
$message = "no_title" if !$params->{title};
# check URL
my $allowed = decode_json($allowed_tags);
my $data = $c->req->json;
- $params->{title} = $c->escape_title($data->{title});
+ $params->{title} = $c->format_htmltext($data->{title}, "title");
$params->{url} = $data->{url};
$params->{email} = $data->{email};
$params->{introtext} = $c->clean_html($allowed, $data->{introtext});
my $data = $c->req->json;
my $message = "";
- $params->{title} = $c->escape_title($data->{title});
+ $params->{title} = $c->format_htmltext($data->{title}, "title");
$message = "no title!" if !$params->{title};
$params->{time} = $data->{createtime};
my $data = $c->req->json;
my $message = "";
- $params->{title} = $c->escape_title($data->{title});
+ $params->{title} = $c->format_htmltext($data->{title}, "title");
$params->{comment} = $c->clean_html($allowed, $data->{comment});
$params->{sid} = $data->{discussion_id};
$params->{stoid} = $data->{stoid};
--- /dev/null
+# -*-Perl-*-
+# PostFilter plugin tests
+
+use Mojo::Base -strict;
+use Test::More;
+use Test::Mojo;
+
+use Newslash::Util::TestMan;
+use Data::Dumper;
+use Newslash::Eventd::Handlers;
+
+my $t = Test::Mojo->new('Newslash::Web');
+
+subtest 'text formatter test' => sub {
+ my $text = <<EOT;
+<p>insiderman曰く、</p><blockquote
+><p>はやくも来年発表されるとみられているiPhoneの新モデルの噂が出始めている(<a href="https://www.theverge.com/circuitbreaker/2017/11/13/16644266/apple-iphone-x-plus-rumor-two-fullscreen-phones-2018">The Verge</a>、<a href="http://jbpress.ismedia.jp/articles/-/51619">JBPress</a>、<a href="https://hardware.slashdot.org/story/17/11/14/000224/apple-could-launch-two-new-full-screen-iphones-next-year">Slashdot</a>)。</p>
+<p>KGI SecuritiesのアナリストMing-Chi Kuo氏による予想では、6.5インチ有機ELディスプレイを搭載したモデルがiPhone Xの新たなモデル(「Plus」バージョン)として出るのではないか、とされている。また、iPhone 8 Plusと同等のサイズでiPhone Xのようにフルスクリーン化した6.1インチ液晶ディスプレイ搭載モデルも出る可能性があるとも予測されている。これは、「ハイエンド市場」のさまざまな需要を狙ったものになるという。iPhone Xはその価格も話題となったが、液晶ディスプレイの採用で価格を下げることができるようだ。</p>
+</blockquote>
+EOT
+
+ my $correct = <<EOT;
+<p>insiderman曰く、</p>
+<blockquote>
+<p>はやくも来年発表されるとみられているiPhoneの新モデルの噂が出始めている(<a href="https://www.theverge.com/circuitbreaker/2017/11/13/16644266/apple-iphone-x-plus-rumor-two-fullscreen-phones-2018">The Verge</a>、<a href="http://jbpress.ismedia.jp/articles/-/51619">JBPress</a>、<a href="https://hardware.slashdot.org/story/17/11/14/000224/apple-could-launch-two-new-full-screen-iphones-next-year">Slashdot</a>)。</p>
+<p>KGI SecuritiesのアナリストMing-Chi Kuo氏による予想では、6.5インチ有機ELディスプレイを搭載したモデルがiPhone Xの新たなモデル(「Plus」バージョン)として出るのではないか、とされている。また、iPhone 8 Plusと同等のサイズでiPhone Xのようにフルスクリーン化した6.1インチ液晶ディスプレイ搭載モデルも出る可能性があるとも予測されている。これは、「ハイエンド市場」のさまざまな需要を狙ったものになるという。iPhone Xはその価格も話題となったが、液晶ディスプレイの採用で価格を下げることができるようだ。</p>
+</blockquote>
+EOT
+
+ my $rs = $t->app->format_htmltext($text, "story");
+ cmp_ok($correct, "eq", $rs, "format_htmltext");
+
+
+};
+
+done_testing();