Parse html tags out of status content before applying filters. (#2713)
Fixes #2660
This commit is contained in:
parent
91d18998ac
commit
9dd3a3d79b
2 changed files with 45 additions and 1 deletions
|
@ -53,6 +53,14 @@ class FilterTest {
|
|||
irreversible = false,
|
||||
wholeWord = true
|
||||
),
|
||||
Filter(
|
||||
id = "123",
|
||||
phrase = "#hashtag",
|
||||
context = listOf(Filter.HOME),
|
||||
expiresAt = null,
|
||||
irreversible = false,
|
||||
wholeWord = true
|
||||
),
|
||||
Filter(
|
||||
id = "123",
|
||||
phrase = "expired",
|
||||
|
@ -69,6 +77,14 @@ class FilterTest {
|
|||
irreversible = false,
|
||||
wholeWord = true
|
||||
),
|
||||
Filter(
|
||||
id = "123",
|
||||
phrase = "href",
|
||||
context = listOf(Filter.HOME),
|
||||
expiresAt = null,
|
||||
irreversible = false,
|
||||
wholeWord = false
|
||||
),
|
||||
)
|
||||
|
||||
filterModel.initWithFilters(filters)
|
||||
|
@ -166,6 +182,33 @@ class FilterTest {
|
|||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun shouldFilterHashtags() {
|
||||
assertTrue(
|
||||
filterModel.shouldFilterStatus(
|
||||
mockStatus(content = "#hashtag one two three")
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun shouldFilterHashtags_whenContentIsMarkedUp() {
|
||||
assertTrue(
|
||||
filterModel.shouldFilterStatus(
|
||||
mockStatus(content = "<p><a href=\"https://foo.bar/tags/hashtag\" class=\"mention hashtag\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">#<span>hashtag</span></a>one two three</p>")
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun shouldNotFilterHtmlAttributes() {
|
||||
assertFalse(
|
||||
filterModel.shouldFilterStatus(
|
||||
mockStatus(content = "<p><a href=\"https://foo.bar/\">https://foo.bar/</a> one two three</p>")
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun shouldNotFilter_whenFilterIsExpired() {
|
||||
assertFalse(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue