プロジェクト

全般

プロフィール

Bug(バグ) #2408

Yuya Watanabe12年以上前に更新

h3. 概要

サイドバナーのRSSリーダーを利用する際,URLに特殊文字が含まれる場合に正しいRSSフィードが得られない.

h3. 確認手順

# pc_backend.php/design/gadget/type/sideBannerで「RSSリーダー」のガジェットを追加する
# 「RSSリーダー」をクリックして下記URLを登録する
<pre>
http://video.baidu.jp/api/search?word=バイク&output=rss&start=0&count=12&sort=dt_recent&adult_filter=1
</pre>
# ログイン画面等のサイドバナーが表示されるページで表示される結果を確認する
** Firefox等の別のRSSリーダーで表示される結果と違う

h3. 原因

下記コード部において$this->gadgetがGadgetクラスをsfOutputEscaperIteratorDecoratorクラスでラップされているため,特殊文字がエスケープされた文字列が取得されてしまう.

apps/pc_frontend/modules/default/actions/components.class.php
<pre>
98 try
99 {
100 $fetcher = new opRssFetcher('UTF-8');
101 $this->result = @$fetcher->fetch($this->gadget->getConfig('url'), true);
102 if ($this->result)
103 {
104 $this->result[1] = array_slice($this->result[1], 0, 5);
105 }
106 }
</pre>

h3. 修正案

# $this->gadgetがsfOutputEscaperIteratorDecoratorクラスでラップせずにGadgetクラスでexecuteRssBox()に渡すようにする
# executeRssBox()内で$this->gadgetのsfOutputEscaperIteratorDecoratorのラップを剥がして値を取得する

h3. 実装案

修正案1の実装方法が確認できなかったため修正案2について実装案を提示.おそらく以下の修正で修正案2に相当すると思われる.
<pre>
diff --git a/apps/pc_frontend/modules/default/actions/components.class.php b/apps/pc_frontend/modules/default/actions/components.class.php
index ad79046..06b97c4 100644
--- a/apps/pc_frontend/modules/default/actions/components.class.php
+++ b/apps/pc_frontend/modules/default/actions/components.class.php
@@ -98,7 +98,7 @@ class defaultComponents extends sfComponents
try
{
$fetcher = new opRssFetcher('UTF-8');
- $this->result = @$fetcher->fetch($this->gadget->getConfig('url'), true);
+ $this->result = @$fetcher->fetch(sfOutputEscaper::unescape($this->gadget)->getConfig('url'), true);
if ($this->result)
{
$this->result[1] = array_slice($this->result[1], 0, 5);
</pre>

h3. 確認バージョン

OpenPNE 3.7.0-dev, 3.6beta13

h3. 実際の修正

各アプリケーションのconfig/settings.ymlのescaping_strategy部分を'on'からtrue,'off'からfalseに置換する.

戻る