From 70345752257a9f16018fa8bdaef3c92a918c92b5 Mon Sep 17 00:00:00 2001 From: JC Brand Date: Mon, 7 Dec 2020 10:20:09 +0100 Subject: [PATCH 1/2] XEP-0372: Determine substring indexing convention The `begin` index is inclusive and the `end` index is exclusive. Standards list discussion: https://mail.jabber.org/pipermail/standards/2020-December/thread.html#37954 --- xep-0372.xml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/xep-0372.xml b/xep-0372.xml index 2450adec..93ca8e95 100644 --- a/xep-0372.xml +++ b/xep-0372.xml @@ -92,7 +92,11 @@ -

References are provided in a 'reference' element of a message, with a namespace of 'urn:xmpp:reference:0'. The element MUST contain a type attribute denoting the type of the reference and a uri attribute of the thing that is referenced. It MAY contain begin, end and anchor elements. A begin attribute is used to mark the index in the body of the referring message of the first character (TODO: define character appropriately) in the reference, with 0 being the index of the first character. An end attribute is similarly used for the index of the last character of the reference. Where the reference is not a substring of the message body in the referring stanza, begin and end are not used. An anchor attribute is used when the referring message is not the one containing the reference element, and points to the previous message containing the reference (the referring message).

+

References are provided in a 'reference' element of a message, with a namespace of 'urn:xmpp:reference:0'. The element MUST contain a 'type' attribute denoting the type of the reference and a 'uri' attribute of the thing that is referenced. It MAY contain 'begin', 'end' and 'anchor' elements.

+

The 'begin' and 'end' attributes are indexes denoting the beginning and end of the referenced substring in the message body. The Dijkstra convention of rangesDijkstra convention of ranges <https://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/EWD831.html> is used, which means that 'begin' is inclusive and 'end' is exclusive. In other words, the 'begin' attribute is the index of the first character (TODO: define character appropriately) in the referenced substring, with 0 being the index of the first character in the body, and the 'end' attribute is one higher than the index of the last character in the substring. + This convention has three main advantages. It matches subsequence indexing in various programming languages, 'end' minus 'begin' equals the length of the substring, and when two substrings are adjacent, the 'end' attribute of the first one matches the 'begin' attribute of the second one. + Where the reference is not a substring of the message body in the referring stanza, 'begin' and 'end' are not used.

+

An 'anchor' attribute is used when the referring message is not the one containing the reference element, and points to the previous message containing the reference (the referring message).

Note that the URIs of the reference and anchor do not need to refer to the same mechanism as that in which the reference was received. E.g., a service could listen for mentions in a MIX channels of users outside that channel, and send them messages containing a reference to let them know that they've been mentioned.

From eb0a7b58922e78c2063cfe5eb857b807854381b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Sch=C3=A4fer?= Date: Tue, 8 Dec 2020 15:05:22 +0100 Subject: [PATCH 2/2] XEP-0372: add revision block --- xep-0372.xml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/xep-0372.xml b/xep-0372.xml index 93ca8e95..9192d98a 100644 --- a/xep-0372.xml +++ b/xep-0372.xml @@ -11,7 +11,7 @@ This document defines a method for one XMPP stanza to provide references to another entity, such as mentioning users, HTTP resources, or other XMPP resources. &LEGALNOTICE; 0372 - Deferred + Experimental Standards Track Standards Council @@ -25,6 +25,12 @@ Refs &ksmithisode; + + 0.4.0 + 2020-12-08 + gh/jcbrand + Specify that begin is inclusive, starts counting at zero, and that end is exclusive (Dijkstra-based convention) + 0.3 2019-09-04