Project

General

Profile

Actions

Backport(バックポート) #2734

closed

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

Added by Yuya Watanabe about 13 years ago. Updated almost 13 years ago.

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

100%

Estimated time:

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 1 (0 open1 closed)

Related to OpenPNE 3 - Bug(バグ) #2323: 半角空白区切りの連続した複数のURLが正常に自動リンクされないFixed(完了)Yuya Watanabe2011-07-29

Actions
Actions #1

Updated by Yuya Watanabe almost 13 years ago

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

Updated by Yuya Watanabe almost 13 years ago

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

更新履歴 1410564def1a0a38470b23ec18aa9b4202f27949 で適用されました。

Actions #3

Updated by Kousuke Ebihara almost 13 years ago

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

Updated by Yuya Watanabe almost 13 years ago

  • Description updated (diff)
Actions #5

Updated by Yuma Sakata almost 13 years ago

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

テストOKです。

Actions #6

Updated by Yuya Watanabe almost 13 years ago

追記

3.4.19 では op_auto_link_text_for_mobile() が定義されていないため,携帯版ではリンクが行われない.
そのため本チケットの問題は 3.4.19 の携帯版では発生していない.

Actions

Also available in: Atom PDF