diff --git a/zerver/lib/actions.py b/zerver/lib/actions.py index fe3cb14561..5ed5f8ab42 100644 --- a/zerver/lib/actions.py +++ b/zerver/lib/actions.py @@ -2284,6 +2284,10 @@ def notify_realm_filters(realm): notice = dict(event=dict(type="realm_filters", realm_filters=realm_filters), users=user_ids) tornado_callbacks.send_notification(notice) +# NOTE: Regexes must be simple enough that they can be easily translated to JavaScript +# RegExp syntax. In addition to JS-compatible syntax, the following features are available: +# * Named groups will be converted to numbered groups automatically +# * Inline-regex flags will be stripped, and where possible translated to RegExp-wide flags def do_add_realm_filter(realm, pattern, url_format_string): RealmFilter(realm=realm, pattern=pattern, url_format_string=url_format_string).save() diff --git a/zerver/management/commands/realm_filters.py b/zerver/management/commands/realm_filters.py index ed8746fe01..10b65ea20d 100644 --- a/zerver/management/commands/realm_filters.py +++ b/zerver/management/commands/realm_filters.py @@ -11,6 +11,12 @@ class Command(BaseCommand): Usage: python manage.py realm_filters foo.com PATTERN URLPATTERN +NOTE: Regexes must be simple enough that they can be easily translated to JavaScript + RegExp syntax. In addition to JS-compatible syntax, the following features are available: + + * Named groups will be converted to numbered groups automatically + * Inline-regex flags will be stripped, and where possible translated to RegExp-wide flags + Example: python manage.py realm_filters --realm=zulip.com --op=add '#(?P[0-9]{2,8})' 'https://trac.humbughq.com/ticket/%(id)s' Example: python manage.py realm_filters --realm=zulip.com --op=remove '#(?P[0-9]{2,8})' Example: python manage.py realm_filters --realm=zulip.com --op=show