JEP-0106: JID Escaping

Allow the display of Jabber Identifiers (JIDs) with characters prohibited by the Nodeprep profile of stringprep.

WARNING: This Standards-Track JEP is Experimental. Publication as a Jabber Enhancement Proposal does not imply approval of this proposal by the Jabber Software Foundation. Implementation of the protocol described herein is encouraged in exploratory implementations, but production systems should not deploy implementations of this protocol until it advances to a status of Draft.

JEP Information

Status: Experimental
Type: Standards Track
Number: 0106
Version: 0.3
Last Updated: 2005-03-16
JIG: Standards JIG
Approving Body: Jabber Council
Dependencies: None
Supersedes: None
Superseded By: None
Short Name: jid#20;escaping

Author Information

Joe Hildebrand


Peter Saint-Andre


Legal Notice

This Jabber Enhancement Proposal is copyright 1999 - 2005 by the Jabber Software Foundation (JSF) and is in full conformance with the JSF's Intellectual Property Rights Policy <>. This material may be distributed only subject to the terms and conditions set forth in the Open Publication License, v1.0 or later (the latest version is presently available at <>).

Discussion Venue

The preferred venue for discussion of this document is the Standards-JIG discussion list: <>.

Relation to XMPP

The Extensible Messaging and Presence Protocol (XMPP) is defined in the XMPP Core (RFC 3920) and XMPP IM (RFC 3921) specifications contributed by the Jabber Software Foundation to the Internet Standards Process, which is managed by the Internet Engineering Task Force in accordance with RFC 2026. Any protocols defined in this JEP have been developed outside the Internet Standards Process and are to be understood as extensions to XMPP rather than as an evolution, development, or modification of XMPP itself.

Conformance Terms

The keywords "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119.

Table of Contents

1. Introduction
2. Requirements
3. Use Cases
3.1. Encoding Transformation
3.2. Decoding Transformation
3.3. Discovery
3.4. Exceptions
4. Rules
5. Security Considerations
6. IANA Considerations
7. Jabber Registrar Considerations
Revision History

1. Introduction

XMPP Core [1] defines the Nodeprep profile of stringprep (RFC 3454 [2]), which specifies that the following characters are invalid in the node identifier portion of a JID:

This restriction is a hardship for users who have these characters in their chosen usernames, particularly in the case of the ' character, which is common in names like O'Hara and D'Artagnan. The restriction is especially onerous if existing email addresses are mapped to JIDs, since some of the foregoing characters are allowed in the username portion of an email address (e.g., the characters & ' / as described in sections 3.2.4 and 3.2.5 of RFC 2822 [3]). If the & character had not been in this list, then normal XML escaping conventions could have been used, and, for example, D'Artagnan could have been rendered as d&apos;artagnan [sic].

Since there are good reasons for each of the prohibited characters above, another escaping mechanism is desirable. Although it might have been desirable to use URL encoding (%27), that approach was rejected since the % character is such an often-used character in JIDs (e.g, to replace the @ character in gateway addresses). Therefore, a new mechanism is described herein to escape only the foregoing characters in the node identifier portion of Jabber IDs.

2. Requirements

This JEP addresses only the following requirements:

  1. The escaping mechanism shall apply to the node identitier portion of a JID only, and MUST NOT be applied to domain identifiers or resource identifiers.
  2. Escaped JIDs MUST conform to the definition of a Jabber ID from the XMPP Core specification, including the Nodeprep profile of stringprep. In particular this means that even after passing through Nodeprep, the JID MUST be valid, so the use of Unicode look-alikes like U+02BC (Modifier Letter Apostrophe) cannot be used.
  3. It MUST NOT be possible for clients to use this escaping mechanism to avoid the goal of stringprep; namely, that JIDs that look alike SHOULD have same character representation after being processed by stringprep. Therefore, this mechanism SHOULD NOT be general-purpose, but specific to only certain characters.
  4. Existing JIDs that include portions of the escaping mechanism MUST continue to be valid.
  5. The escaping mechanism SHOULD NOT place undue strain upon server implementations; implementations that do not need to unescape SHOULD be able to ignore the escaping mechanism.

3. Use Cases

All transformations are exactly as specified. CASE IS SIGNIFICANT. Lowercase was selected since Nodeprep will case fold to lowercase.

3.1 Encoding Transformation

The following escaping transformations MAY be used by a conforming entity. Typically, this will only be done by a client that is retrieving information from a user in unescaped form, or by a gateway to some external system (e.g., email or LDAP) that needs to generate a JID.

Table 1: Mapping from Unescaped to Encoded Characters

Unescaped Character Encoded Character
<space> #20;
" #22;
# #23;
& #26;
' #27;
/ #2f;
: #3a;
< #3c;
> #3e;
@ #40;

Example 1. JID Encoding: Porthos starts a chat, typing into his client the JID d'

  <body>And do you always forget your eyes when you run?</body>

3.2 Decoding Transformation

The opposite unescaping transformations MAY be used by a conforming entity. Typically, this is only done by a client that wants to display JIDs, or by a gateways to some external system (e.g., email or LDAP) that needs to generate identifiers for foreign systems.

Table 2: Mapping from Encoded to Decoded Characters

Encoded Character Decoded Character
#20; <space>
#22; "
#23; #
#26; &
#27; '
#2f; /
#3a; :
#3c; <
#3e; >
#40; @

Example 2. JID Encoding: D'Artagnan the elder sends SMTP mail through a gateway:

  <body>I recommend my son to you.</body>

3.3 Discovery

If a client is going to encode identifiers for use by a gateway, the client needs to know which encoding scheme to use. A client MUST assume that the gateway does not support this encoding scheme, unless it discovers that the service supports the jid#20;escaping [sic] feature. Namely, if there any errors in the disco exchange, or the jid#20;escaping feature is not discovered, the client SHOULD use the 'jabber:iq:gateway' protocol (as specified in Gateway Interaction [4]) if the gateway supports that protocol, or use traditional escaping mechanisms (such as the transformation ofthe @ character to the % character) if support for either jid#20;escaping or jabber:iq:gateway cannot be determined.

Example 3. Client requests features

  <query xmlns=''/>

Example 4. Service responds with features

  <query xmlns=''>
    <feature var='jid#20;escaping'/>

3.4 Exceptions

In order to maintain as much backward compatibility as possible, JIDs that contain partial escape sequences, or escape sequences that are not on the list, MUST be ignored.

Example 5. Partial escape sequence

foo#bar is not modified by escaping or unescaping transformations

Example 6. Invalid escape sequence

foob#41;r is not modified by escaping or unescaping transformations

4. Rules

As far as the bulk of the system is concerned, an escaped JID has no special processing associated with it. Clients SHOULD render them unescaped. Servers MAY unescape them for communication with external systems (e.g. LDAP), but only AFTER stringprep has been applied. The unescape transformation MUST be NFKC-safe -- i.e., it must conform to Unicode normalization form KC (see Appendix B.3 of RFC 3454). An entity MUST NOT use the unescaped version in any protocol sent to another entity, and MUST NOT use the unescaped version to compare with another JID.

5. Security Considerations

Entities that enforce JID escaping MUST compare unescaped versions, otherwise a JID conflict could occur.

6. IANA Considerations

This JEP requires no interaction with the Internet Assigned Numbers Authority (IANA) [5].

7. Jabber Registrar Considerations

The Jabber Registrar [6] shall include the jid#20;escaping [sic] feature in its registry of service discovery features.


1. RFC 3920: Extensible Messaging and Presence Protocol (XMPP): Core <>.

2. RFC 3454: Preparation of Internationalized Strings (stringprep) < >.

3. RFC 2822: Internet Message Format <>.

4. JEP-0100: Gateway Interaction <>.

5. The Internet Assigned Numbers Authority (IANA) is the central coordinator for the assignment of unique parameter values for Internet protocols, such as port numbers and URI schemes. For further information, see <>.

6. The Jabber Registrar maintains a list of reserved Jabber protocol namespaces as well as registries of parameters used in the context of protocols approved by the Jabber Software Foundation. For further information, see <>.

Revision History

Version 0.3 (2005-03-16)

Clarified relationship between JID escaping and traditional client proxy gateway behavior; fixed several small errors. (psa)

Version 0.2 (2003-10-21)

Editorial cleanup; added security considerations. (psa)

Version 0.1 (2003-07-21)

Initial version. (jjh)