Skip to content

Commit 64c61c2

Browse files
authored
Properly separate Room ID and Event ID grammars (matrix-org#1484)
1 parent e9fc66c commit 64c61c2

File tree

6 files changed

+44
-12
lines changed

6 files changed

+44
-12
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Clarifications of event ID formats in early room versions
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Clarifications of event ID formats in early room versions

content/appendices.md

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ allocated by that homeserver.
520520
The precise grammar defining the allowable format of an identifier
521521
depends on the type of identifier. For example, event IDs can sometimes
522522
be represented with a `domain` component under some conditions - see the
523-
[Event IDs](#room-ids-and-event-ids) section below for more information.
523+
[Event IDs](#event-ids) section below for more information.
524524

525525
#### User Identifiers
526526

@@ -629,22 +629,19 @@ allowing representation of *any* character (unlike punycode, which
629629
provides no way to encode ASCII punctuation).
630630
{{% /boxes/rationale %}}
631631

632-
#### Room IDs and Event IDs
632+
#### Room IDs
633633

634634
A room has exactly one room ID. A room ID has the format:
635635

636636
!opaque_id:domain
637637

638-
An event has exactly one event ID. The format of an event ID depends
639-
upon the [room version specification](/rooms).
640-
641638
The `domain` of a room ID is the [server name](#server-name) of the
642-
homeserver which created the room/event. The domain is used only for
639+
homeserver which created the room. The domain is used only for
643640
namespacing to avoid the risk of clashes of identifiers between
644-
different homeservers. There is no implication that the room or event in
641+
different homeservers. There is no implication that the room in
645642
question is still available at the corresponding homeserver.
646643

647-
Event IDs and Room IDs are case-sensitive. They are not meant to be
644+
Room IDs are case-sensitive. They are not meant to be
648645
human-readable. They are intended to be treated as fully opaque strings
649646
by clients.
650647

@@ -661,7 +658,21 @@ homeserver to look up the alias.
661658
Room aliases MUST NOT exceed 255 bytes (including the `#` sigil and the
662659
domain).
663660

664-
#### URIs
661+
#### Event IDs
662+
663+
An event has exactly one event ID. Event IDs take the form:
664+
665+
$opaque_id
666+
667+
However, the precise format depends upon the [room version
668+
specification](/rooms): early room versions included a `domain` component,
669+
whereas more recent versions omit the domain and use a base64-encoded hash instead.
670+
671+
Event IDs are case-sensitive. They are not meant to be human-readable. They are
672+
intended to be treated as fully opaque strings by clients.
673+
674+
675+
### URIs
665676

666677
There are two major kinds of referring to a resource in Matrix: matrix.to
667678
and `matrix:` URI. The specification currently defines both as active/valid
@@ -672,7 +683,7 @@ be used to reference particular objects in a given context, such as mentioning
672683
a user in a message or linking someone to a particular point in the room's
673684
history (a permalink).
674685

675-
##### Matrix URI scheme
686+
#### Matrix URI scheme
676687

677688
{{% added-in v="1.2" %}}
678689

@@ -777,7 +788,7 @@ Examples of common URIs are:
777788
A suggested client implementation algorithm is available in the
778789
[original MSC](https://github.com/matrix-org/matrix-spec-proposals/blob/main/proposals/2312-matrix-uri.md#recommended-implementation).
779790

780-
##### matrix.to navigation
791+
#### matrix.to navigation
781792

782793
{{% boxes/note %}}
783794
This namespacing existed prior to a `matrix:` scheme. This is **not**
@@ -841,7 +852,7 @@ matrix.to URIs pointing to groups might still exist: they take the form
841852
may not be encoded).
842853
{{% /boxes/note %}}
843854

844-
##### Routing
855+
#### Routing
845856

846857
Room IDs are not routable on their own as there is no reliable domain to
847858
send requests to. This is partially mitigated with the addition of a
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
An event has exactly one event ID. Event IDs in this room version have the
2+
format:
3+
4+
$opaque_id:domain
5+
6+
where `domain` is the [server name](/appendices/#server-name) of the homeserver
7+
which created the room, and `opaque_id` is a locally-unique string.
8+
9+
The domain is used only for namespacing to avoid the risk of clashes of
10+
identifiers between different homeservers. There is no implication that the
11+
room or event in question is still available at the corresponding homeserver.

content/rooms/v1.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ inconsistencies may occur.
4242

4343
[See above](#redactions).
4444

45+
### Event IDs
46+
47+
{{% rver-fragment name="v1-event-ids" %}}
48+
4549
### Event format
4650

4751
Events in version 1 rooms have the following structure:

content/rooms/v2.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ completeness.
4040

4141
{{% rver-fragment name="v1-redactions" %}}
4242

43+
### Event IDs
44+
45+
{{% rver-fragment name="v1-event-ids" %}}
46+
4347
### Event format
4448

4549
Events in rooms of this version have the following structure:

0 commit comments

Comments
 (0)