mirror of https://github.com/zulip/zulip.git
realm_filters: Allows more use of & and friends in URLs.
We had some excessively tight rules about what characters were allowed, which in particular prevented using `?foo=bar&baz=quux` structures in the realm filters URLs. Fixes #12239.
This commit is contained in:
parent
6f6e87f45d
commit
0f2d7a354f
|
@ -656,7 +656,7 @@ def filter_pattern_validator(value: str) -> None:
|
|||
raise ValidationError(error_msg)
|
||||
|
||||
def filter_format_validator(value: str) -> None:
|
||||
regex = re.compile(r'^([\.\/:a-zA-Z0-9#_?=-]+%\(([a-zA-Z0-9_-]+)\)s)+[a-zA-Z0-9_-]*$')
|
||||
regex = re.compile(r'^([\.\/:a-zA-Z0-9#_?=&-]+%\(([a-zA-Z0-9_-]+)\)s)+[/a-zA-Z0-9#_?=&-]*$')
|
||||
|
||||
if not regex.match(value):
|
||||
raise ValidationError(_('Invalid URL format string.'))
|
||||
|
|
|
@ -58,25 +58,25 @@ class RealmFilterTest(ZulipTestCase):
|
|||
self.assertIsNotNone(re.match(data['pattern'], 'ZUL2-15'))
|
||||
|
||||
data['pattern'] = r'_code=(?P<id>[0-9a-zA-Z]+)'
|
||||
data['url_format_string'] = 'https://realm.com/my_realm_filter/?value=%(id)s'
|
||||
data['url_format_string'] = 'https://example.com/product/%(id)s/details'
|
||||
result = self.client_post("/json/realm/filters", info=data)
|
||||
self.assert_json_success(result)
|
||||
self.assertIsNotNone(re.match(data['pattern'], '_code=123abcdZ'))
|
||||
|
||||
data['pattern'] = r'PR (?P<id>[0-9]+)'
|
||||
data['url_format_string'] = 'https://realm.com/my_realm_filter/?value=%(id)s'
|
||||
data['url_format_string'] = 'https://example.com/web#view_type=type&model=model&action=12345&id=%(id)s'
|
||||
result = self.client_post("/json/realm/filters", info=data)
|
||||
self.assert_json_success(result)
|
||||
self.assertIsNotNone(re.match(data['pattern'], 'PR 123'))
|
||||
|
||||
data['pattern'] = r'lp/(?P<id>[0-9]+)'
|
||||
data['url_format_string'] = 'https://realm.com/my_realm_filter/?value=%(id)s'
|
||||
data['url_format_string'] = 'https://realm.com/my_realm_filter/?value=%(id)s&sort=reverse'
|
||||
result = self.client_post("/json/realm/filters", info=data)
|
||||
self.assert_json_success(result)
|
||||
self.assertIsNotNone(re.match(data['pattern'], 'lp/123'))
|
||||
|
||||
data['pattern'] = r'lp:(?P<id>[0-9]+)'
|
||||
data['url_format_string'] = 'https://realm.com/my_realm_filter/?value=%(id)s'
|
||||
data['url_format_string'] = 'https://realm.com/my_realm_filter/?sort=reverse&value=%(id)s'
|
||||
result = self.client_post("/json/realm/filters", info=data)
|
||||
self.assert_json_success(result)
|
||||
self.assertIsNotNone(re.match(data['pattern'], 'lp:123'))
|
||||
|
|
Loading…
Reference in New Issue