File tree 2 files changed +4
-7
lines changed
2 files changed +4
-7
lines changed Original file line number Diff line number Diff line change @@ -159,12 +159,10 @@ final object RawHtml {
159
159
last + 1
160
160
}
161
161
162
- private [this ] val imgurRegex = """ https?://imgur\.com/(\w+)""" .r
163
- private [this ] val imgUrlPat = """ \.(?:jpg|jpeg|png|gif)$""" .r.pattern
162
+ private [this ] val imgurRegex = """ https?://(?:i\.)?imgur\.com/(\w+)(?:\.jpe?g|\.png|\.gif)?""" .r
164
163
165
164
private [this ] def imgUrl (url : String ): Option [String ] = (url match {
166
165
case imgurRegex(id) => Some (s """ https://i.imgur.com/ $id.jpg """ )
167
- case _ if imgUrlPat.matcher(url).find => Some (url)
168
166
case _ => None
169
167
}) map { img => s """ <img class="embed" src=" $img" alt=" $url"/> """ }
170
168
Original file line number Diff line number Diff line change @@ -35,11 +35,10 @@ class RawHtmlTest extends Specification {
35
35
val url = " http://foo@bar"
36
36
addLinks(s """ link to $url here """ ) must not contain (""" href="http://foo"""" )
37
37
}
38
- " detect image" in {
38
+ " ignore image from untrusted host " in {
39
39
val url = " http://zombo.com/pic.jpg"
40
- addLinks(s """ img to $url here """ ) must_== {
41
- s """ img to <img class="embed" src=" $url" alt=" $url"/> here """
42
- }
40
+ addLinks(s """ link to $url here """ ) must_==
41
+ s """ link to <a rel="nofollow" href=" $url" target="_blank"> $url</a> here """
43
42
}
44
43
" detect imgur image URL" in {
45
44
val url = " https://imgur.com/NXy19Im"
You can’t perform that action at this time.
0 commit comments