diff --git a/CHANGELOG.md b/CHANGELOG.md index e470a3a..fcd8726 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -63,6 +63,8 @@ * Don't try to relay AP payloads to Diaspora receivers and vice versa, for now, until cross-protocol relaying is supported. + +* Fix some characters stopping tags being identified ([related issue](https://git.feneas.org/socialhome/socialhome/-/issues/222)) ## [0.19.0] - 2019-12-15 diff --git a/federation/tests/utils/test_text.py b/federation/tests/utils/test_text.py index 8f406c1..fc39abe 100644 --- a/federation/tests/utils/test_text.py +++ b/federation/tests/utils/test_text.py @@ -34,12 +34,12 @@ class TestFindTags: assert text == "foo\n```\n#code\n```\n#notcode/notcode\n\n #alsocode\n" def test_endings_are_filtered_out(self): - source = "#parenthesis) #exp! #list]" + source = "#parenthesis) #exp! #list] *#doh* _#bah_ #gah%" tags, text = find_tags(source) - assert tags == {"parenthesis", "exp", "list"} + assert tags == {"parenthesis", "exp", "list", "doh", "bah", "gah"} assert text == source tags, text = find_tags(source, replacer=self._replacer) - assert text == "#parenthesis/parenthesis) #exp/exp! #list/list]" + assert text == "#parenthesis/parenthesis) #exp/exp! #list/list] *#doh/doh* _#bah/bah_ #gah/gah%" def test_finds_tags(self): source = "#post **Foobar** #tag #OtherTag #third\n#fourth" diff --git a/federation/utils/text.py b/federation/utils/text.py index 93bf311..7cbe206 100644 --- a/federation/utils/text.py +++ b/federation/utils/text.py @@ -50,7 +50,7 @@ def find_tags(text: str, replacer: callable = None) -> Tuple[Set, str]: words = line.split(" ") for word in words: if word.find('#') > -1: - candidate = word.strip().strip("([]),.!?:") + candidate = word.strip().strip("([]),.!?:*_%") if candidate.find('<') > -1 or candidate.find('>') > -1: # Strip html candidate = bleach.clean(word, strip=True)