Skip to content
This repository has been archived by the owner on Nov 10, 2017. It is now read-only.

Commit

Permalink
URL中に文字参照が入っていても許容するよう変更
Browse files Browse the repository at this point in the history
ただし、>はアンカーと被るので弾く。
  • Loading branch information
awef committed Nov 12, 2012
1 parent 016eb2a commit e65ceb2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/test/UI.ThreadContent.spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,15 @@ describe "UI.ThreadContent", ->
hogehoge()
return

it "URL中に文字参照が入っていても許容する", ->
example.a.data1.message = "test http://goo.gl/e?1&1 test"
example.a.dom1.querySelector(".message").innerHTML = """
test <a href="http://goo.gl/e?1&amp;1" target="_blank">http://goo.gl/e?1&amp;1</a> test
"""

hogehoge()
return

it "URLは空白文字以外と隣接していても認識する", ->
example.a.data1.message = "テストhttp://goo.gl/eテスト"
example.a.dom1.querySelector(".message").innerHTML = """
Expand Down
2 changes: 1 addition & 1 deletion src/ui/ThreadContent.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ class UI.ThreadContent
#タグ除去
.replace(/<(?!(?:br|hr|\/?b)>).*?(?:>|$)/ig, "")
#URLリンク
.replace(/(h)?(ttps?:\/\/(?:[a-hj-zA-HJ-Z\d_\-.!~*'();\/?:@=+$,%#]|\&(?!(?:#(\d+)|#x([\dA-Fa-f]+)|([\da-zA-Z]+));)|[iI](?![dD]:)+)+)/g,
.replace(/(h)?(ttps?:\/\/(?:[a-hj-zA-HJ-Z\d_\-.!~*'();\/?:@=+$,%#]|\&(?!gt;)|[iI](?![dD]:)+)+)/g,
'<a href="h$2" target="_blank">$1$2</a>')
#Beアイコン埋め込み表示
.replace ///^\s*sssp://(img\.2ch\.net/ico/[\w\-_]+\.gif)\s*<br>///, ($0, $1) =>
Expand Down

0 comments on commit e65ceb2

Please sign in to comment.