Project

General

Profile

Backport(バックポート) #2733

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

Added by Yuya Watanabe over 7 years ago. Updated over 7 years ago.

Status:
Fixed(完了)
Priority:
Normal(通常)
Assignee:
Target version:
Start date:
2011-07-29
Due date:
% Done:

100%


Description

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

Related issues

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

Associated revisions

Revision 745b86e9 (diff)
Added by Yuya Watanabe over 7 years ago

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

BP from #2323
a242107d3d94c5b454036de6ac7be7fa23c47b93

History

#1 Updated by Yuya Watanabe over 7 years ago

  • Status changed from New(新規) to Accepted(着手)
  • Assignee set to Yuya Watanabe

#2 Updated by Yuya Watanabe over 7 years ago

  • Status changed from Accepted(着手) to Pending Review(レビュー待ち)
  • % Done changed from 0 to 50

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

#3 Updated by Kousuke Ebihara over 7 years ago

  • Status changed from Pending Review(レビュー待ち) to Pending Testing(テスト待ち)
  • % Done changed from 50 to 70

#4 Updated by Yuya Watanabe over 7 years ago

  • Description updated (diff)

#5 Updated by Yuma Sakata over 7 years ago

  • Status changed from Pending Testing(テスト待ち) to Fixed(完了)
  • % Done changed from 70 to 100

テストOKです。

Also available in: Atom PDF