Skip to content

Commit

Permalink
Loosen the inet:web:hashtag regex a bit, resolves SYN-7452 (#3751)
Browse files Browse the repository at this point in the history
  • Loading branch information
rakuy0 authored Jun 14, 2024
1 parent 5f42645 commit 6f18bfd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion synapse/models/inet.py
Original file line number Diff line number Diff line change
Expand Up @@ -1415,7 +1415,7 @@ def getModelDefs(self):
'doc': 'A channel within a web service or instance such as slack or discord.'
}),

('inet:web:hashtag', ('str', {'lower': True, 'regex': r'^#[\w]+$'}), {
('inet:web:hashtag', ('str', {'lower': True, 'regex': r'^#\w[\w·]*(?<!·)$'}), {
'doc': 'A hashtag used in a web post.',
}),

Expand Down
7 changes: 6 additions & 1 deletion synapse/tests/test_model_inet.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import copy
import logging

import synapse.exc as s_exc
Expand All @@ -12,10 +11,16 @@ class InetModelTest(s_t_utils.SynTest):
async def test_model_inet_basics(self):
async with self.getTestCore() as core:
self.len(1, await core.nodes('[ inet:web:hashtag="#hehe" ]'))
self.len(1, await core.nodes('[ inet:web:hashtag="#foo·bar"]')) # note the interpunct
self.len(1, await core.nodes('[ inet:web:hashtag="#fo·o·······b·ar"]'))
with self.raises(s_exc.BadTypeValu):
await core.nodes('[ inet:web:hashtag="foo" ]')
with self.raises(s_exc.BadTypeValu):
await core.nodes('[ inet:web:hashtag="#foo bar" ]')
with self.raises(s_exc.BadTypeValu):
self.len(1, await core.nodes('[ inet:web:hashtag="#·bar"]'))
with self.raises(s_exc.BadTypeValu):
self.len(1, await core.nodes('[ inet:web:hashtag="#foo·"]'))

nodes = await core.nodes('''
[ inet:web:instance=(foo,)
Expand Down

0 comments on commit 6f18bfd

Please sign in to comment.