プロジェクト

全般

プロフィール

Backport(バックポート) #2733

半角空白区切りの連続した複数のURLが正常に自動リンクされない

Yuya Watanabe約12年前に追加. 約12年前に更新.

ステータス:
Fixed(完了)
優先度:
Normal(通常)
担当者:
対象バージョン:
開始日:
2011-07-29
期日:
進捗率:

100%


説明

Overview (現象)

半角空白区切りの連続した複数のURLが正常に自動リンクされない

詳細

日記本文で現象を確認

書き込み内容
http://example.com/ http://example.com/hoge http://example.com/fuga http://example.com/hoge
ブラウザ出力結果(HTML)
<div class="title">
<p class="heading">test</p>
</div>
<div class="body">
<a href="http://example.com/" target="_blank">http://example.com/</a> http://example.com/hoge <a href="http://example.com/fuga" target="_blank">http://example.com/fuga</a> http://example.com/hoge</div>
</dd>
</dl>

Causes (原因)

リンクを生成する際に URL を正規表現でマッチさせているが,これがプレフィックスとして空白文字を考慮していない.

lib/helper/opUtilHelper.php 313-317行目

 310 if (!defined('SF_AUTO_LINK_RE'))
 311 {
 312   define('SF_AUTO_LINK_RE', '~
 313     (                       # leading text
 314       <\w+.*?>|             #   leading HTML tag, or
 315       [^=!:\'"/]|           #   leading punctuation, or
 316       ^                     #   beginning of line, or
 317     )                             
 318     (                             
 319       (?:https?://)|        # protocol spec, or
 320       (?:www\.)             # www.*
 321     )                             
 322     (                     
 323       [-\w]+                   # subdomain or domain
 324       (?:\.[-\w]+)*            # remaining subdomains or domain
 325       (?::\d+)?                # port
 326       \/?                 
 327       [a-zA-Z0-9_\-\/.,:;\~\?@&=+$%#!()]*
 328     )                     
 329     ([[:punct:]]|\s|<|$)    # trailing text
 330    ~x');                  
 331 }                         

Way to fix (修正内容)

正規表現で URL にマッチさせる際に空白文字を考慮する.

diff --git a/lib/helper/opUtilHelper.php b/lib/helper/opUtilHelper.php
index 59d22bc..d918493 100644
--- a/lib/helper/opUtilHelper.php
+++ b/lib/helper/opUtilHelper.php
@@ -313,7 +313,8 @@ if (!defined('SF_AUTO_LINK_RE'))
     (                       # leading text
       <\w+.*?>|             #   leading HTML tag, or
       [^=!:\'"/]|           #   leading punctuation, or
-      ^                     #   beginning of line
+      ^|                    #   beginning of line, or
+      \s?                   #   leading whitespaces
     )
     (
       (?:https?://)|        # protocol spec, or

関連するチケット

関連している OpenPNE 3 - Bug(バグ) #2323: 半角空白区切りの連続した複数のURLが正常に自動リンクされない Fixed(完了) 2011-07-29
関連している opDiaryPlugin - Bug(バグ) #2380: 日記の本文に記述したURLが自動リンクされない場合がある Invalid(無効) 2011-08-29

関係しているリビジョン

リビジョン 745b86e9 (差分)
Yuya Watanabe約12年前に追加

(fixes #2733, BP from #2323) fixed to put links automatically when the text has whitespaces

BP from #2323
a242107d3d94c5b454036de6ac7be7fa23c47b93

履歴

#1 Yuya Watanabe約12年前に更新

  • ステータスNew(新規) から Accepted(着手) に変更
  • 担当者Yuya Watanabe にセット

#2 Yuya Watanabe約12年前に更新

  • ステータスAccepted(着手) から Pending Review(レビュー待ち) に変更
  • 進捗率0 から 50 に変更

更新履歴 745b86e9d1ce6f3410b8d5e7817d97e74988439e で適用されました。

#3 Kousuke Ebihara約12年前に更新

  • ステータスPending Review(レビュー待ち) から Pending Testing(テスト待ち) に変更
  • 進捗率50 から 70 に変更

#4 Yuya Watanabe約12年前に更新

  • 説明 を更新 (diff)

#5 Yuma Sakata約12年前に更新

  • ステータスPending Testing(テスト待ち) から Fixed(完了) に変更
  • 進捗率70 から 100 に変更

テストOKです。

他の形式にエクスポート: Atom PDF