Skip to content

Commit afae108

Browse files
authored
Clarify what key content-specific rules match against. (matrix-org#1441)
1 parent b441b19 commit afae108

File tree

7 files changed

+26
-20
lines changed

7 files changed

+26
-20
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Clarify what event property the content-specific push rules match against.

content/appendices.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -934,6 +934,14 @@ The `address` is the telephone number represented as a MSISDN (Mobile
934934
Station International Subscriber Directory Number) as defined by the
935935
E.164 numbering plan. Note that MSISDNs do not include a leading '+'.
936936

937+
## Glob-style matching
938+
939+
It is useful to match strings via globbing in some situations. Globbing in Matrix
940+
uses the following rules:
941+
942+
* The character `*` matches zero or more characters.
943+
* `?` matches exactly one character.
944+
937945
## Security Threat Model
938946

939947
### Denial of Service

content/client-server-api/modules/moderation_policies.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ technique for receiving updates to the policy's rules.
7575

7676
#### Events
7777

78-
The `entity` described by the state events can contain `*` and `?` to
79-
match zero or more characters and exactly one character respectively. Note that
78+
The `entity` described by the state events is interpreted as a
79+
[glob-style pattern](/appendices#glob-style-matching). Note that
8080
rules against rooms can describe a room ID or room alias - the
8181
subscriber is responsible for resolving the alias to a room ID if
8282
desired.

content/client-server-api/modules/push.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,12 @@ The different `kind`s of rule, in the order that they are checked, are:
155155
1. **Content-specific rules (`content`).**
156156
These configure behaviour for (unencrypted) messages that match certain
157157
patterns. Content rules take one parameter: `pattern`, that gives the
158-
glob pattern to match against. This is treated in the same way as
159-
`pattern` for `event_match`.
158+
[glob-style pattern](/appendices#glob-style-matching) to match against.
159+
The match is performed case-insensitively, and must match any substring of
160+
the `content.body` property which starts and ends at a word boundary. A word
161+
boundary is defined as the start or end of the value, or any character not
162+
in the sets `[A-Z]`, `[a-z]`, `[0-9]` or `_`.The exact meaning of
163+
"case insensitive" is defined by the implementation of the homeserver.
160164

161165
1. **Room-specific rules (`room`).**
162166
These rules change the behaviour of all messages for a given room. The
@@ -264,18 +268,13 @@ This is a glob pattern match on a field of the event. Parameters:
264268
- `key`: The dot-separated path of the property of the event to match, e.g.
265269
`content.body`.
266270

267-
- `pattern`: The glob-style pattern to match against.
271+
- `pattern`: The [glob-style pattern](/appendices#glob-style-matching) to match against.
268272

269273
The match is performed case-insensitively, and must match the entire value of
270274
the event field given by `key` (though see below regarding `content.body`). The
271275
exact meaning of "case insensitive" is defined by the implementation of the
272276
homeserver.
273277

274-
Within `pattern`:
275-
276-
* The character `*` matches zero or more characters.
277-
* `?` matches exactly one character.
278-
279278
If the property specified by `key` is completely absent from the event, or does
280279
not have a string value, then the condition will not match, even if `pattern`
281280
is `*`.

data/api/client-server/definitions/push_condition.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ properties:
3434
pattern:
3535
type: string
3636
description: |-
37-
Required for `event_match` conditions. The glob-style pattern to
38-
match against.
37+
Required for `event_match` conditions. The [glob-style pattern](/appendices#glob-style-matching)
38+
to match against.
3939
is:
4040
type: string
4141
description: |-

data/api/client-server/definitions/push_rule.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ properties:
4646
pattern:
4747
type: string
4848
description: |-
49-
The glob-style pattern to match against. Only applicable to `content`
50-
rules.
49+
The [glob-style pattern](/appendices#glob-style-matching) to match against.
50+
Only applicable to `content` rules.
5151
required:
5252
- actions
5353
- default

data/event-schemas/schema/m.room.server_acl.yaml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ description: |-
77
server ACL. Servers that do not uphold the ACLs MUST be added to the denied hosts
88
list in order for the ACLs to remain effective.
99
10-
The `allow` and `deny` lists are lists of globs supporting `?` and `*`
11-
as wildcards. When comparing against the server ACLs, the suspect server's port
10+
The `allow` and `deny` lists are lists of [glob-style patterns](/appendices#glob-style-matching).
11+
When comparing against the server ACLs, the suspect server's port
1212
number must not be considered. Therefore `evil.com`, `evil.com:8448`, and
1313
`evil.com:1234` would all match rules that apply to `evil.com`, for example.
1414
@@ -61,8 +61,7 @@ properties:
6161
type: array
6262
description: |-
6363
The server names to allow in the room, excluding any port information.
64-
Wildcards may be used to cover a wider range of hosts, where `*`
65-
matches zero or more characters and `?` matches exactly one character.
64+
Each entry is interpreted as a [glob-style pattern](/appendices#glob-style-matching).
6665
6766
**This defaults to an empty list when not provided, effectively disallowing
6867
every server.**
@@ -72,8 +71,7 @@ properties:
7271
type: array
7372
description: |-
7473
The server names to disallow in the room, excluding any port information.
75-
Wildcards may be used to cover a wider range of hosts, where `*`
76-
matches zero or more characters and `?` matches exactly one character.
74+
Each entry is interpreted as a [glob-style pattern](/appendices#glob-style-matching).
7775
7876
This defaults to an empty list when not provided.
7977
items:

0 commit comments

Comments
 (0)