No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

xep-0106.xml 40KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458
  1. <?xml version='1.0' encoding='UTF-8'?>
  2. <!DOCTYPE xep SYSTEM 'xep.dtd' [
  3. <!ENTITY % ents SYSTEM 'xep.ent'>
  4. %ents;
  5. ]>
  6. <?xml-stylesheet type='text/xsl' href='xep.xsl'?>
  7. <xep>
  8. <header>
  9. <title>JID Escaping</title>
  10. <abstract>This specification defines a mechanism that enables the display in Jabber Identifiers (JIDs) of characters normally disallowed in localparts. Although these characters &mdash; spaces, double quote, ampersand, single quote, forward slash, colon, less than, greater than, and at-sign &mdash; cannot be included in XMPP localparts, JID Escaping provides a native XMPP escaping mechanism for these characters so that the displayed version of a Jabber Identifier can appear to include these characters. This mechanism can also be used to translate non-XMPP addreses into XMPP syntax, for example when gatewaying between XMPP and a non-XMPP communications technology such as email.</abstract>
  11. &LEGALNOTICE;
  12. <number>0106</number>
  13. <status>Draft</status>
  14. <type>Standards Track</type>
  15. <sig>Standards</sig>
  16. <dependencies>
  17. <spec>XMPP Core</spec>
  18. <spec>XEP-0030</spec>
  19. </dependencies>
  20. <supersedes/>
  21. <supersededby/>
  22. <shortname>jid\20escaping</shortname>
  23. &hildjj;
  24. &stpeter;
  25. <revision>
  26. <version>1.1.1</version>
  27. <date>2016-07-08</date>
  28. <initials>ssw</initials>
  29. <remark><p>Update references to the node identifier to localpart, replace stringprep references with PRECIS, and update JID RFC references.</p></remark>
  30. </revision>
  31. <revision>
  32. <version>1.1</version>
  33. <date>2007-06-18</date>
  34. <initials>psa</initials>
  35. <remark><p>Specified that \20 must not be included at the beginning or end of a node identifier; added security consideration regarding potential confusion caused by mismatch between software that does and software that does not perform JID escaping; added note about existing native JIDs that contain escaped characters; added mapping for IRC addresses; modified terminology to consistently use the terms escaping and unescaping rather than the terms encoding and decoding.</p></remark>
  36. </revision>
  37. <revision>
  38. <version>1.0</version>
  39. <date>2005-05-12</date>
  40. <initials>psa</initials>
  41. <remark><p>Per a vote of the Jabber Council, advanced status to Draft.</p></remark>
  42. </revision>
  43. <revision>
  44. <version>0.7</version>
  45. <date>2005-05-08</date>
  46. <initials>psa</initials>
  47. <remark><p>Added examples of transforming JIDs to non-XMPP address formats.</p></remark>
  48. </revision>
  49. <revision>
  50. <version>0.6</version>
  51. <date>2005-05-06</date>
  52. <initials>psa</initials>
  53. <remark><p>Changed format from #xx; to \xx per list discussion; added extensive implementation notes.</p></remark>
  54. </revision>
  55. <revision>
  56. <version>0.5</version>
  57. <date>2005-04-21</date>
  58. <initials>psa</initials>
  59. <remark><p>Changed to U+00xx format for code points; added references to various RFCs; corrected terminology; cleaned up text and flow.</p></remark>
  60. </revision>
  61. <revision>
  62. <version>0.4</version>
  63. <date>2005-04-04</date>
  64. <initials>psa</initials>
  65. <remark><p>Corrected several small textual errors and ambiguities; slightly reorganized textual flow.</p></remark>
  66. </revision>
  67. <revision>
  68. <version>0.3</version>
  69. <date>2005-03-16</date>
  70. <initials>psa</initials>
  71. <remark><p>Clarified relationship between JID escaping and traditional client proxy gateway behavior; fixed several small errors.</p></remark>
  72. </revision>
  73. <revision>
  74. <version>0.2</version>
  75. <date>2003-10-21</date>
  76. <initials>psa</initials>
  77. <remark><p>Editorial cleanup; added security considerations.</p></remark>
  78. </revision>
  79. <revision>
  80. <version>0.1</version>
  81. <date>2003-07-21</date>
  82. <initials>jjh</initials>
  83. <remark><p>Initial published version.</p></remark>
  84. </revision>
  85. </header>
  86. <section1 topic='Introduction' anchor='intro'>
  87. <p>&rfc7622; specifies that the following eight Unicode code points are disallowed in the localpart of a Jabber Identifier (JID):</p>
  88. <ul>
  89. <li>U+0022 (")</li>
  90. <li>U+0026 (&amp;)</li>
  91. <li>U+0027 (')</li>
  92. <li>U+002F (/)</li>
  93. <li>U+003A (:)</li>
  94. <li>U+003C (&lt;)</li>
  95. <li>U+003E (&gt;)</li>
  96. <li>U+0040 (@)</li>
  97. </ul>
  98. <p>Furthermore, since localparts use the UsernameCaseMapped profile (&rfc7613;) of PRECIS any space character disallowed by category N (section 9.14) of the &rfc7564; IdentifierClass is also forbidden.</p>
  99. <p>This restriction is an inconvenience for users who have one or more of these "disallowed characters" in their desired usernames, particularly in the case of the apostrophe character, which is common in names like O'Hara and D'Artagnan. The restriction is a positive hardship if existing email addresses are mapped to JIDs, since some of the disallowed characters are allowed in the username portion of an email address (specifically, the characters &amp; ' / as described in Sections 3.2.3 and 3.2.4 of &rfc5322;).</p>
  100. <p>To overcome this restriction, we define a way to escape the disallowed characters in JIDs. An escaped JID contains none of the disallowed characters and therefore can be transported by native XMPP implementations without modification (e.g., existing XMPP servers do not require modification in order to handle escaped JIDs). The escaped JID is unescaped only for presentation to a human user (typically by an XMPP client) or for gatewaying to a non-XMPP system (such as an LDAP database or a messaging system that does not use XMPP).</p>
  101. </section1>
  102. <section1 topic='Requirements' anchor='reqs'>
  103. <p>This document addresses the following requirements:</p>
  104. <ol>
  105. <li><p>The escaping mechanism shall apply to the localpart of a JID only, and MUST NOT be applied to domainparts or resourceparts.</p></li>
  106. <li><p>Escaped JIDs MUST conform to the definition of a Jabber ID as specified in <cite>RFC 7622</cite>, including the UsernameCaseMapped profile of PRECIS. In particular this means that even after passing through the enforcement step of the UsernameCaseMapped profile, the JID MUST be valid, with the result that Unicode look-alikes like U+02BC (Modifier Letter Apostrophe) MUST NOT be used.</p></li>
  107. <li><p>It MUST NOT be possible for clients to use this escaping mechanism to avoid the goal of PRECIS; namely, that JIDs that look alike should have same character representation after being processed by PRECIS. Therefore, this mechanism MUST NOT be applied to any characters other than the disallowed characters (with the exception that, in certain circumstances, the escaping character itself ("\") might also be escaped).</p></li>
  108. <li><p>Existing JIDs that include portions of the escaping mechanism MUST continue to be valid.</p></li>
  109. <li><p>The escaping mechanism MUST NOT break commonly deployed Jabber/XMPP software implementations such as servers, components, gateways, and clients.</p></li>
  110. <li><p>The escaping mechanism SHOULD NOT place undue strain upon server implementations; implementations or deployments that do not need to unescape SHOULD be able to ignore the escaping mechanism.</p></li>
  111. </ol>
  112. </section1>
  113. <section1 topic='Transformations' anchor='transforms'>
  114. <section2 topic='Concepts' anchor='concepts'>
  115. <p>This document specifies that each disallowed character shall be escaped as \hexhex &mdash; where "hexhex" is the hexadecimal value of the Unicode code point in question, ignoring the leading "00" in the code point (e.g., 27 for the apostrophe character, resulting in an escaping of \27).</p>
  116. <p>If the &amp; character had not been in the list of disallowed characters, then normal XML escaping conventions (as specified in &w3xml;) could have been used, with the result that D'Artagnan (for example) could have been rendered as D&amp;apos;artagnan [sic].</p>
  117. <p>It might have been desirable to use percent-encoding (e.g., %27 for the apostrophe character) as specified in Section 2.1 of &rfc3986;. However, that approach was rejected since the % character is an often-used character in existing JIDs (e.g., to replace the @ character in gateway addresses) and the resulting ambiguity would have caused misdelivered or undeliverable messages.</p>
  118. <p>To avoid the problems associated with using &amp; or % as the escaping character, this document specifies a new escaping mechanism that uses the backslash character ("\") followed by "hexhex" (the hexadecimal value of the Unicode code point in question). This escaping method is quite similar to that used for disallowed characters in LDAP distinguished names (see &rfc2253;) but is used only for the characters that are disallowed in XMPP localparts (as well as the escaping character itself in certain special situations).</p>
  119. <p>Here is an example of an escaped JID (this would be displayed but never natively transported as "d'artagnan@musketeers.lit"):</p>
  120. <code>
  121. d\27artagnan@musketeers.lit
  122. </code>
  123. <p>This document describes full escaping and unescaping transformations for all disallowed characters. In addition, escaping and unescaping transformations are shown for the \ character in case it also needs to be escaped when it occurs in a JID or non-XMPP address as part of a character sequence that corresponds to one of the escaped characters.</p>
  124. <p>Note: All transformations are exactly as specified below. CASE IS SIGNIFICANT. Lowercase was selected since the Case-Mapping Rule of the UsernameCaseMapped profile will case fold to lowercase.</p>
  125. </section2>
  126. <section2 topic='Escaping Transformations' anchor='escaping'>
  127. <p>The escaping transformations are defined in the following table, whereas the rules that define when to apply these transformations are specified in the <link url='#bizrules'>Business Rules</link> section of this specification. Typically, escaping is performed only by a client that is processing information provided by a human user in unescaped form, or by a gateway to some external system (e.g., email or LDAP) that needs to generate a JID.</p>
  128. <table caption='Mapping from Unescaped to Escaped Characters'>
  129. <tr><th>Unescaped Character</th><th>Escaped Character</th></tr>
  130. <tr><td>&lt;space&gt;</td><td>\20 *</td></tr>
  131. <tr><td>"</td><td>\22</td></tr>
  132. <tr><td>&amp;</td><td>\26</td></tr>
  133. <tr><td>'</td><td>\27</td></tr>
  134. <tr><td>/</td><td>\2f</td></tr>
  135. <tr><td>:</td><td>\3a</td></tr>
  136. <tr><td>&lt;</td><td>\3c</td></tr>
  137. <tr><td>&gt;</td><td>\3e</td></tr>
  138. <tr><td>@</td><td>\40</td></tr>
  139. <tr><td>\</td><td>\5c</td></tr>
  140. </table>
  141. <p>* Note: The character sequence \20 MUST NOT be the first or last character of an escaped localpart. <note>For a similar restriction, see Section 2.4 of <cite>RFC 2253</cite>.</note></p>
  142. <p>In the following example, Porthos starts a chat with D'Artagnan, typing into his client the string "d'artagnan@musketeers.lit" (which is escaped by his client to "d\27artagnan@musketeers.lit").</p>
  143. <example caption="JID Escaping"><![CDATA[
  144. <message
  145. from='porthos@musketeers.lit/gate'
  146. to='d\27artagnan@musketeers.lit'
  147. type='chat'>
  148. <body>And do you always forget your eyes when you run?</body>
  149. </message>
  150. ]]></example>
  151. </section2>
  152. <section2 topic='Unescaping Transformations' anchor='unescaping'>
  153. <p>The unescaping transformations are defined in the following table, whereas the rules that define when to apply these transformations are specified in the <link url='#bizrules'>Business Rules</link> section of this specification. Typically, unescaping is performed only by a client that wants to display JIDs containing escaped characters to a human user, or by a gateway to some external system (e.g., email or LDAP) that needs to generate identifiers for foreign systems.</p>
  154. <table caption='Mapping from Escaped to Unescaped Characters'>
  155. <tr><th>Escaped Character</th><th>Unescaped Character</th></tr>
  156. <tr><td>\20</td><td>&lt;space&gt;</td></tr>
  157. <tr><td>\22</td><td>"</td></tr>
  158. <tr><td>\26</td><td>&amp;</td></tr>
  159. <tr><td>\27</td><td>'</td></tr>
  160. <tr><td>\2f</td><td>/</td></tr>
  161. <tr><td>\3a</td><td>:</td></tr>
  162. <tr><td>\3c</td><td>&lt;</td></tr>
  163. <tr><td>\3e</td><td>&gt;</td></tr>
  164. <tr><td>\40</td><td>@</td></tr>
  165. <tr><td>\5c</td><td>\</td></tr>
  166. </table>
  167. <p>In the following example, D'Artagnan the elder sends a message through an SMTP mail gateway (the JID is "treville\40musketeers.lit@smtp.gascon.fr" and the destination email address is "treville@musketeers.lit").</p>
  168. <example caption="JID Unescaping"><![CDATA[
  169. <message
  170. from='d\27artagnan@gascon.fr/elder'
  171. to=']]>tr&#xe9;ville\40musketeers.lit@smtp.gascon.fr<![CDATA['>
  172. <body>I recommend my son to you.</body>
  173. </message>
  174. ]]></example>
  175. </section2>
  176. </section1>
  177. <section1 topic='Business Rules' anchor='bizrules'>
  178. <section2 topic='Native Processing' anchor='bizrules-processing'>
  179. <p>The following processing rules apply to native XMPP implementations:</p>
  180. <ol>
  181. <li><p>A compliant client MUST render an escaped character as its unescaped equivalent when presenting it to a human user (e.g., present \27 as the apostrophe character), but MAY provide a way for the user to view the escaped JID in its wire format (e.g., to compare two JIDs).</p></li>
  182. <li><p>A server or gateway MAY unescape an escaped character for communication with external systems (e.g. LDAP), but only <em>after</em> the UsernameCaseMapped profile of PRECIS has been applied.</p></li>
  183. <li><p>An entity MUST unescape only the specified sequences and MUST NOT unescape sequences that do not match the specified sequences.</p></li>
  184. <li><p>An entity MUST NOT include the unescaped version of a disallowed character over the wire in any XML stanzas sent to another entity.</p></li>
  185. <li><p>An entity MUST NOT use the unescaped version of a disallowed character when comparing two JIDs.</p></li>
  186. <li><p>The character sequence \20 MUST NOT be the first or last character of an escaped localpart.</p></li>
  187. <li><p>If there are any instances of character sequences that correspond to escapings of the disallowed characters (e.g., the character sequence "\27") or the escaping character (i.e., the character sequence "\5c") in the unescaped address, the leading backslash character MUST be escaped to the character sequence "\5c" (e.g., resulting in the character sequences "\5c27" or "\5c5c"). <note>It is possible that some existing JIDs already contain character sequences matching "\5chexhex" (where "hexhex" is the hexadecimal value of the Unicode code point for a disallowed character or the backslash character), which may result in confusion between escaped JIDs and their presentation in a client; however, a survey of one large XMPP deployment yielded no instances of such sequences or even of the character sequence "\5c".</note></p></li>
  188. </ol>
  189. </section2>
  190. <section2 topic='Address Transformation Algorithm' anchor='bizrules-algorithm'>
  191. <p>When transforming a non-XMPP ("source") address into an escaped JID, an implementation MUST adhere to the following process:</p>
  192. <ol>
  193. <li><p>If the source address is a URI, it MUST first be properly decoded according to the rules in <cite>RFC 3986</cite> before it is transformed into a JID.</p></li>
  194. <li><p>If the source address is a URI, the URI scheme component MUST be removed.</p></li>
  195. <li><p>If there are any instances of character sequences that correspond to escapings of the disallowed characters (e.g., the character sequence "\27") or the escaping character (i.e., the character sequence "\5c") in the source address, the leading backslash character MUST be escaped to the character sequence "\5c" (e.g., resulting in the character sequences "\5c27" or "\5c5c").</p></li>
  196. <li><p>All disallowed characters in the source address MUST be properly escaped in the resulting JID (as described above).</p></li>
  197. </ol>
  198. <p>While the fourth step should be clear from the foregoing text and the second step is necessary since XMPP addresses are not URIs, the meaning of the first and third steps may not be obvious.</p>
  199. <p>Regarding step one, many non-XMPP messaging systems use URIs to identify addresses (examples include the mailto:, sip:, sips:, im:, pres:, and wv: URI schemes) or follow some other encoding rules for an identifier (e.g., an LDAP distinguished name). Before transforming a non-XMPP address or identifier into a JID, the address or identifier MUST first be decoded according the rules specified for that type of address or identifier in order to ensure that the proper characters are transformed.</p>
  200. <p>Regarding step three, it is possible for some non-XMPP addresses to contain character sequences that correspond to JID-escaped characters (e.g., "\27"). Consider a Wireless Village address of &lt;wv:\3and\2is\5cool@example.com&gt; &mdash; if that address were directly converted into a JID, the resulting XMPP address would be \3and\2is\5cool@example.com, which could be construed as :nd\2is\ool@example.com if JID escaping logic is applied. Therefore the leading \ character and the \ character before the character sequence 5c MUST be converted to the character sequence "\5c" during the transformation, leading to a JID of \5c3and\2is\5c5cool@example.com (which would be presented to a human user as \3and\2is\5cool@example.com).</p>
  201. </section2>
  202. <section2 topic='Exceptions' anchor='bizrules-exceptions'>
  203. <p>In order to maintain as much backward compatibility as possible, partial escape sequences and escape sequences corresponding to characters not on the list of disallowed characters MUST be ignored (with the exception of the escaping character '\' itself in the rare case when the source address includes the sequence '\5c').</p>
  204. <example caption='Partial escape sequence'>"\2plus\2is\4" is not modified by escaping or unescaping transformations.</example>
  205. <example caption='Invalid escape sequence 1'>"foo\bar" is not modified (to "foo&#186;r") by escaping or unescaping transformations.</example>
  206. <example caption='Invalid escape sequence 2'>"foob\41r" is not modified (to "foobAr") by escaping or unescaping transformations.</example>
  207. <p>However, \5c would be escaped if found in the source address (e.g., a source address of "c:\5commas@example.com" would be escaped to "c\3a\5c5commas@example.com") and unescaped if contained in the JID-on-the-wire (e.g., a JID-on-the-wire of "c\3a\5c5commas@example.com" would be unescaped back to "c:\5commas@example.com").</p>
  208. </section2>
  209. <section2 topic='JID Escaping vs. Older Methods' anchor='bizrules-othermethods'>
  210. <p>When a client attempts to communicate with another entity through a gateway, it needs to know which escaping mechanism to use. A client MUST assume that the gateway does not support the JID escaping mechanism unless it explicitly discovers support for the <strong>jid\20escaping</strong> [sic] feature as described under <link url='#disco'>Determining Support</link>. If there are any errors in the service discovery exchange or if support for JID escaping is not discovered, the client SHOULD proceed as follows:</p>
  211. <ol>
  212. <li>If the gateway supports the 'jabber:iq:gateway' protocol (as specified in &xep0100;), use that protocol.</li>
  213. <li>If the gateway does not support the 'jabber:iq:gateway' protocol, use customary escaping mechanisms (such as transformation of the @ character to the % character).</li>
  214. </ol>
  215. </section2>
  216. </section1>
  217. <section1 topic='Examples' anchor='examples'>
  218. <p>In order to assist developers, this section shows a large number of examples for XMPP-native JIDs as well as mappings between JIDs and addresses or identifiers used in the following standardized protocols:</p>
  219. <ul>
  220. <li>Mailboxes and the mailto: URI scheme as used in email.</li>
  221. <li>The sip: and sips: URI schemes as used in SIP/SIMPLE.</li>
  222. <li>The im: and pres: URI schemes.</li>
  223. <li>The wv: URI scheme as used in Wireless Village (IMPS).</li>
  224. <li>LDAP distinguished names.</li>
  225. </ul>
  226. <section2 topic='Jabber Identifiers' anchor='examples-xmpp'>
  227. <p>The following table shows user input, the escaped JID for sending over the wire, and client display (same as user input) for the localpart that might possibly be used in native JIDs. The examples are numbered for easy reference. Naturally, a client that does not perform JID escaping would display the JIDs in their escaped form (e.g., "space\20cadet" instead of "space cadet").</p>
  228. <table caption='JID Examples'>
  229. <tr><th>#</th><th>User Input</th><th>Escaped JID</th><th>Client Display</th></tr>
  230. <tr><td>1</td><td>space&#160;cadet@example.com</td><td>space\20cadet@example.com</td><td>space&#160;cadet@example.com</td></tr>
  231. <tr><td>2</td><td>call&#160;me&#160;"ishmael"@example.com</td><td>call\20me\20\22ishmael\22@example.com</td><td>call&#160;me&#160;"ishmael"@example.com</td></tr>
  232. <tr><td>3</td><td>at&amp;t&#160;guy@example.com</td><td>at\26t\20guy@example.com</td><td>at&amp;t&#160;guy@example.com</td></tr>
  233. <tr><td>4</td><td>d'artagnan@example.com</td><td>d\27artagnan@example.com</td><td>d'artagnan@example.com</td></tr>
  234. <tr><td>5</td><td>/.fanboy@example.com</td><td>\2f.fanboy@example.com</td><td>/.fanboy@example.com</td></tr>
  235. <tr><td>6</td><td>::foo::@example.com</td><td>\3a\3afoo\3a\3a@example.com</td><td>::foo::@example.com</td></tr>
  236. <tr><td>7</td><td>&lt;foo&gt;@example.com</td><td>\3cfoo\3e@example.com</td><td>&lt;foo&gt;@example.com</td></tr>
  237. <tr><td>8</td><td>user@host@example.com</td><td>user\40host@example.com</td><td>user@host@example.com</td></tr>
  238. <tr><td>9</td><td>c:\net@example.com</td><td>c\3a\net@example.com</td><td>c:\net@example.com</td></tr>
  239. <tr><td>10</td><td>c:\\net@example.com</td><td>c\3a\\net@example.com</td><td>c:\\net@example.com</td></tr>
  240. <tr><td>11</td><td>c:\cool stuff@example.com</td><td>c\3a\cool\20stuff@example.com</td><td>c:\cool stuff@example.com</td></tr>
  241. <tr><td>12</td><td>c:\5commas@example.com</td><td>c\3a\5c5commas@example.com</td><td>c:\5commas@example.com</td></tr>
  242. </table>
  243. </section2>
  244. <section2 topic='Email Addresses' anchor='examples-email'>
  245. <p>The address format for an Internet mailbox is specified in <cite>RFC 5322</cite>. The identifier of interest in this context is the "addr-spec" address and more particularly the "dot-atom-text" rule specified in Section 3.2.3, i.e., the email address shorn of angle brackets, display names, comments, quoted strings, and the like. Because some deployments of XMPP messaging systems may want to re-use existing email addresses as JIDs, it is helpful to define how to transform an email address into a JID.</p>
  246. <p>In general, it is straightforward to transform an email address (i.e., a "dot-atom-text") into a JID, since traditional email addresses allow US-ASCII characters only rather than the nearly full range of Unicode code points allowed in a JID. <note>This specification does not cover recent efforts to define internationalized email addresses.</note> However, there are three characters allowed in the localpart of an email address that are not allowed in the localpart portion of a JID: namely, the characters &amp; ' / as described in Sections 3.2.3 and 3.2.4 of <cite>RFC 5322</cite>. In order to transform these characters, a compliant implementation MUST use the methods specified herein.</p>
  247. <example caption='An Email Address Containing JID-Disallowed Characters'><![CDATA[
  248. here's_a_wild_&_/cr%zy/_address@example.com
  249. ]]></example>
  250. <example caption='The Transformed JID'><![CDATA[
  251. here\27s_a_wild_\26_\2fcr%zy\2f_address@example.com
  252. ]]></example>
  253. <example caption='The JID as Presented to a User'><![CDATA[
  254. here's_a_wild_&_/cr%zy/_address@example.com
  255. ]]></example>
  256. <p>(Note: Because the backslash character is forbidden in the "dot-atom-text" construction, an email address should not contain a character sequence that corresponds to one of the escaped characters specified in the <link url="#transforms">Transformations</link> section of this document; therefore, no such examples are shown.)</p>
  257. <p>An email address may also exist in the form of a mailto: URI as specified in &rfc2368;. Before transforming a mailto: URI into a JID, it MUST be URL-decoded and all headers MUST be removed, leaving a mailbox identifier, as shown in the following example.</p>
  258. <example caption='A mailto: URI Containing JID-Disallowed Characters'><![CDATA[
  259. mailto:here%27s_a_wild_%26_%2Fcr%zy%2F_address@example.com?subject=that%20is%20crazy%21
  260. ]]></example>
  261. <example caption='The Resulting Mailbox'><![CDATA[
  262. here's_a_wild_&_/cr%zy/_address@example.com
  263. ]]></example>
  264. <example caption='The Transformed JID'><![CDATA[
  265. here\27s_a_wild_\26_\2fcr%zy\2f_address@example.com
  266. ]]></example>
  267. <example caption='The JID as Presented to a User'><![CDATA[
  268. here's_a_wild_&_/cr%zy/_address@example.com
  269. ]]></example>
  270. <p>The foregoing examples showed how to transform an email address or mailto: URI into a JID. However, it also may be necessary to convert a JID into an email address or mailto: URI, as shown in the following example.</p>
  271. <example caption='User Enters Address, Including Disallowed Characters'><![CDATA[
  272. here's_a_wild_&_/cr%zy/_address@example.com
  273. ]]></example>
  274. <example caption='Client Transforms Address Using JID Escaping'><![CDATA[
  275. here\27s_a_wild_\26_\2fcr%zy\2f_address@example.com
  276. ]]></example>
  277. <example caption='Application Converts Escaped JID to Mailbox'><![CDATA[
  278. here's_a_wild_&_/cr%zy/_address@example.com
  279. ]]></example>
  280. <example caption='Application Converts Mailbox to mailto: URI'><![CDATA[
  281. mailto:here%27s_a_wild_%26_%2Fcr%zy%2F_address@example.com
  282. ]]></example>
  283. </section2>
  284. <section2 topic='SIP Addresses' anchor='examples-sip'>
  285. <p>As specified in &rfc3261;, a SIP address (i.e., a sip: or sips: URI) can be quite complex if URI parameters or headers are included. However, a basic SIP address (the combination of the optional "userinfo" and required "hostport" constructions) is essentially similar to an email address (e.g., the same characters &amp; ' / allowed in an email address but disallowed in an XMPP localpart are also allowed in a basic SIP address).</p>
  286. <example caption='A Basic sip: URI Containing JID-Disallowed Characters'><![CDATA[
  287. sip:here%27s_a_wild_%26_%2Fcr%zy%2F_address@example.com
  288. ]]></example>
  289. <example caption='The URL-Decoded Address'><![CDATA[
  290. here's_a_wild_&_/cr%zy/_address@example.com
  291. ]]></example>
  292. <example caption='The Transformed JID'><![CDATA[
  293. here\27s_a_wild_\26_\2fcr%zy\2f_address@example.com
  294. ]]></example>
  295. <example caption='The JID as Presented to a User'><![CDATA[
  296. here's_a_wild_&_/cr%zy/_address@example.com
  297. ]]></example>
  298. <p>The foregoing example showed how to transform a sip: or sips: URI into a JID. However, it also may be necessary to convert a JID into a sip: or sips: URI, as shown in the following example.</p>
  299. <example caption='User Enters Address, Including Disallowed Characters'><![CDATA[
  300. here's_a_wild_&_/cr%zy/_address@example.com
  301. ]]></example>
  302. <example caption='Client Transforms Address Using JID Escaping'><![CDATA[
  303. here\27s_a_wild_\26_\2fcr%zy\2f_address@example.com
  304. ]]></example>
  305. <example caption='Application Converts Escaped JID to sip: URI'><![CDATA[
  306. sip:here%27s_a_wild_%26_%2Fcr%zy%2F_address@example.com
  307. ]]></example>
  308. </section2>
  309. <section2 topic='IM and Presence Addresses' anchor='examples-im'>
  310. <p>The im: and pres: URI schemes are specified in &rfc3860; and &rfc3859; respectively. With the exception of headers, an im: or pres: URI is simply a mailbox (as specified in <cite>RFC 5322</cite>) prepended with the im: or pres: scheme. Thus a basic IM or PRES address (not including optional headers) is essentially similar to an email address (e.g., the same characters &amp; ' / allowed in an email address but disallowed in an XMPP localpart are also allowed in a basic IM or PRES address).</p>
  311. <example caption='A Basic im: URI Containing JID-Disallowed Characters'><![CDATA[
  312. im:here%27s_a_wild_%26_%2Fcr%zy%2F_address@example.com
  313. ]]></example>
  314. <example caption='The URL-Decoded Address'><![CDATA[
  315. here's_a_wild_&_/cr%zy/_address@example.com
  316. ]]></example>
  317. <example caption='The Transformed JID'><![CDATA[
  318. here\27s_a_wild_\26_\2fcr%zy\2f_address@example.com
  319. ]]></example>
  320. <example caption='The JID as Presented to a User'><![CDATA[
  321. here's_a_wild_&_/cr%zy/_address@example.com
  322. ]]></example>
  323. <p>The foregoing example showed how to transform an im: or pres: URI into a JID. However, it also may be necessary to convert a JID into an im: or pres: URI, as shown in the following example.</p>
  324. <example caption='User Enters Address, Including Disallowed Characters'><![CDATA[
  325. here's_a_wild_&_/cr%zy/_address@example.com
  326. ]]></example>
  327. <example caption='Client Transforms Address Using JID Escaping'><![CDATA[
  328. here\27s_a_wild_\26_\2fcr%zy\2f_address@example.com
  329. ]]></example>
  330. <example caption='Application Converts Escaped JID to pres: URI'><![CDATA[
  331. pres:here%27s_a_wild_%26_%2Fcr%zy%2F_address@example.com
  332. ]]></example>
  333. </section2>
  334. <section2 topic='IMPS Addresses' anchor='examples-imps'>
  335. <p>The Instant Messaging and Presence Service (IMPS) protocol was originally defined by the Wireless Village consortium and is now maintained by the &OMA;. An IMPS address is formatted as a wv: URI, as specified in &wv-csp;. A basic address (not including a private resource) is of the form &lt;wv:user-id@domain&gt; and an address with a private resource is of the form &lt;wv:user-id/resource@domain&gt;.</p>
  336. <p>The "User-ID" construction is either a mobile phone number (beginning with "+1" for international numbers and a digit for national numbers) or an "Internet-Identity". An "Internet-Identity" may contain any US-ASCII character other than / @ + SP TAB and thus may include the following characters that are disallowed in the localpart of a JID: " &amp; ' / : &lt; &gt; (which characters MUST be escaped when transforming an IMPS address into a JID). However, some of those characters are also reserved in URI syntax (namely the &amp; ' / characters) so those characters will be found in escaped form within a wv: URI.</p>
  337. <example caption='A Basic wv: URI Containing JID-Disallowed Characters'><![CDATA[
  338. wv:here%27s_a_wild_%26_%2Fcr%zy%2F_address_for%3A%3Cwv%3E%28%22IMPS%22%29@example.com
  339. ]]></example>
  340. <example caption='The URL-Decoded Address'><![CDATA[
  341. here's_a_wild_&_/cr%zy/_address_for:<wv>("IMPS")@example.com
  342. ]]></example>
  343. <example caption='The Transformed JID'><![CDATA[
  344. here\27s_a_wild_\26_\2fcr%zy\2f_address_for\3a\3cwv\3e(\22IMPS\22)@example.com
  345. ]]></example>
  346. <example caption='The JID as Presented to a User'><![CDATA[
  347. here's_a_wild_&_/cr%zy/_address_for:<wv>("IMPS")@example.com
  348. ]]></example>
  349. <p>Unlike the foregoing address types, IMPS addresses are allowed to contain backslashes. This implies that it is possible for an IMPS address to contain a character sequence that corresponds to one of the escaped character representations for code points that are disallowed in XMPP localparts. An example would be the IMPS address &lt;wv:\3and\2is\5cool@example.com&gt;, where the character sequence "\3a" could be interpreted as the : character (and the character sequence "\5c" as "\") if that IMPS address is directly converted into a JID. Therefore, the leading \ character MUST be transformed to "\5c" (and the source character sequence "\5c" to "\5c5c") in order to avoid possible ambiguity. Thus the transformed JID would be &lt;\5c3and\2is\5c5cool@example.com&gt;, which would be presented to a user as &lt;\3and\2is\5cool@example.com&gt;.</p>
  350. <p>If an IMPS address contains a private resource, a gateway between XMPP and IMPS should process the resource and append it to the end of the JID; however, such gateway behavior is out of scope for this document.</p>
  351. <p>The foregoing example showed how to transform a wv: URI into a JID. However, it also may be necessary to convert a JID into a wv: URI, as shown in the following example.</p>
  352. <example caption='User Enters Address, Including Disallowed Characters'><![CDATA[
  353. here's_a_wild_&_/cr%zy/_address_for:<wv>("IMPS")@example.com
  354. ]]></example>
  355. <example caption='Client Transforms Address Using JID Escaping'><![CDATA[
  356. here\27s_a_wild_\26_\2fcr%zy\2f_address_for\3a\3cwv\3e(\22IMPS\22)@example.com
  357. ]]></example>
  358. <example caption='Application Converts Escaped JID to wv: URI'><![CDATA[
  359. wv:here%27s_a_wild_%26_%2Fcr%zy%2F_address_for%3A%3Cwv%3E%28%22IMPS%22%29@example.com
  360. ]]></example>
  361. </section2>
  362. <section2 topic='LDAP Distinguished Names' anchor='examples-ldap'>
  363. <p>Within the Lightweight Directory Access Protocol (see &rfc2251;), a "distinguished name" (DN) is a hierarchically-organized string representation that uniquely identifies a user, system, or organization. It is possible that some messaging systems use LDAP distinguished names to identify entities that can communicate using the system (e.g., this is reputed to be the case for certain releases of the Lotus Sametime system sold by IBM), and in any case it may be helpful to transform an LDAP distinguished name into an XMPP address for identification or addressing purposes.</p>
  364. <p>As previously mentioned, a UTF-8 string representation of LDAP distinguished names is specified in <cite>RFC 2253</cite>. This representation specifies that the characters , + " \ &lt; &gt; ; are to be escaped with the backslash character (e.g., the character sequence "\," would be used to escape the , character) and that any other non-US-ASCII characters are to be escaped using a character sequence of the form "\xx".</p>
  365. <p>The following example shows a distinguished name (and transformations thereof) for a person whose common name is "D'Artagnan Saint-Andr&#233;" and who is associated with an organization called "Example &amp; Company, Inc." whose domain name is "example.com":</p>
  366. <example caption='A Distinguished Name'>
  367. CN=D'Artagnan Saint-Andr&#xe9;,O=Example &amp; Company, Inc.,DC=example,DC=com
  368. </example>
  369. <example caption='UTF-8 Representation of Distinguished Name'><![CDATA[
  370. CN=D'Artagnan Saint-Andr\E9,O=Example &amp; Company\, Inc.,DC=example,DC=com
  371. ]]></example>
  372. <p>This example assumes that the specified user is identified with a gateway running at st.example.com (note that the backslash escaping the , character in the organization name is removed during the transformation).</p>
  373. <example caption='The Transformed JID'><![CDATA[
  374. CN=D\27Artagnan\20Saint-Andr\E9,O=Example\20\26\20Company,\20Inc.,DC=example,DC=com@st.example.com
  375. ]]></example>
  376. <example caption='The JID as Presented to a User'>
  377. CN=D'Artagnan Saint-Andr&#xe9;,O=Example &amp; Company, Inc.,DC=example,DC=com@st.example.com
  378. </example>
  379. <p>Naturally, a more intelligent gateway could use the Domain Components to construct a more readable JID, such as &lt;D\27Artagnan\20Saint-Andr&#xe9;@example.com&gt;; however, such gateway behavior is out of scope for this document.</p>
  380. <p>The foregoing example showed how to transform an LDAP distinguished name into a JID. However, it also may be necessary to convert a JID into an LDAP distinguished name, as shown in the following example.</p>
  381. <example caption='User Enters Address, Including Disallowed Characters'><![CDATA[
  382. CN=D'Artagnan Saint-Andr&#xe9;,O=Example &amp; Company, Inc.,DC=example,DC=com@st.example.com
  383. ]]></example>
  384. <example caption='Client Transforms Address Using JID Escaping'><![CDATA[
  385. CN=D\27Artagnan\20Saint-Andr\E9,O=Example\20\26\20Company,\20Inc.,DC=example,DC=com@st.example.com
  386. ]]></example>
  387. <example caption='Application Converts Escaped JID to UTF-8 Representation of LDAP Distinguished Name'><![CDATA[
  388. CN=D'Artagnan Saint-Andr\E9,O=Example &amp; Company\, Inc.,DC=example,DC=com
  389. ]]></example>
  390. <example caption='Application Converts UTF-8 Representation to LDAP Distinguished Name'>
  391. CN=D'Artagnan Saint-Andr&#xe9;,O=Example &amp; Company, Inc.,DC=example,DC=com
  392. </example>
  393. </section2>
  394. <section2 topic='IRC Addresses' anchor='examples-irc'>
  395. <p>&rfc2812; defines the address format for Internet Relay Chat (IRC) entities, which can be servers, channels, or users. The "user" portion of an IRC address may contain any octet except NUL, CR, LF, SP, and "@"; this includes the characters " &amp; ' / : &lt; &gt; \ (which are disallowed in XMPP localparts and therefore MUST be escaped when transforming an IRC address into a JID).</p>
  396. <example caption='A Basic IRC address Containing JID-Disallowed Characters'><![CDATA[
  397. somenick!user"&'/:<>\3address@example.com
  398. ]]></example>
  399. <example caption='The Transformed JID'><![CDATA[
  400. somenick!user\22\26\27\2f\3a\3c\3e\5c3address@example.com
  401. ]]></example>
  402. <example caption='The JID as Presented to a User'><![CDATA[
  403. somenick!user"&'/:<>\3address@example.com
  404. ]]></example>
  405. <p>Like IMPS addresses, IRC addresses are allowed to contain backslashes. This implies that it is possible for an IMPS address to contain a character sequence that corresponds to one of the escaped character representations for code points that are disallowed in XMPP localparts. An example is shown above.</p>
  406. </section2>
  407. </section1>
  408. <section1 topic='Determining Support' anchor='disco'>
  409. <p>If an entity needs to determine whether another entity supports JID escaping, it MUST send a disco#info request to the other entity as specified in &xep0030;.</p>
  410. <example caption='Client requests features'><![CDATA[
  411. <iq type='get'
  412. from='porthos@musketeers.lit/gate'
  413. to='irc.shakespeare.lit'
  414. id='info1'>
  415. <query xmlns='http://jabber.org/protocol/disco#info'/>
  416. </iq>
  417. ]]></example>
  418. <p>If the queried entity supports JID escaping, it MUST return a <strong>jid\20escaping</strong> [sic] feature in its reply.</p>
  419. <example caption='Service responds with features'><![CDATA[
  420. <iq type='get'
  421. to='porthos@musketeers.lit/gate'
  422. from='irc.shakespeare.lit'
  423. id='info1'>
  424. <query xmlns='http://jabber.org/protocol/disco#info'>
  425. ...
  426. <feature var='jid\20escaping'/>
  427. </query>
  428. </iq>
  429. ]]></example>
  430. </section1>
  431. <section1 topic='Security Considerations' anchor='security'>
  432. <p>If an entity (e.g., a client or a gateway) performs JID escaping, it MUST do so consistently (for example, a client or server MUST consistently apply JID escaping and unescaping to the JIDs it handles) so that the entity does not present the same JID in two different ways or present two different JIDs in the same way.</p>
  433. <p>Naturally, if one entity performs JID escaping and another entity does not perform JID escaping, the same JID could be presented differently by those entities (e.g., the JID d\27artagnan@musketeers.lit would be presented as d'artagnan@musketeers.lit by a client that performs JID escaping but as d\27artagnan@musketeers.lit by a client that does not perform JID escaping). By the same token, two different JIDs could be presented in the same way by those entities (e.g., the JID foo\5cbar@example.com would be presented as foo\bar@example.com by a client that performs JID escaping and the JID foo\bar@example.com would be presented as foo\bar@example.com by a client that does not perform JID escaping). These differing presentations could be a source of confusion (e.g., the same human user could use two different clients, one of which performs JID escaping and one of which does not). This confusion may have security implications since in rare instances messages and other information could be directed to an entity other than the intended recipient; unfortunately, this is unavoidable until all XMPP clients support JID escaping.</p>
  434. <p>An entity that performs JID escaping MUST NOT compare unescaped versions, otherwise messages and other information could be directed to an entity other than the intended recipient.</p>
  435. <p>An entity that transforms a non-XMPP address into a JID MUST follow the algorithm specified in the <link url="#bizrules-algorithm">Address Transformation Algorithm</link> section of this document, otherwise messages and other information could be directed to an entity other than the intended recipient.</p>
  436. </section1>
  437. <section1 topic='IANA Considerations' anchor='iana'>
  438. <p>This document requires no interaction with &IANA;.</p>
  439. </section1>
  440. <section1 topic='XMPP Registrar Considerations' anchor='registrar'>
  441. <section2 topic='Service Discovery Features' anchor='registrar-features'>
  442. <p>The &REGISTRAR; includes the <strong>jid\20escaping</strong> [sic] feature in its registry of service discovery features.</p>
  443. </section2>
  444. </section1>
  445. <section1 topic='Acknowledgements' anchor='ack'>
  446. <p>The authors would like to thank Robin Redeker for his feedback.</p>
  447. </section1>
  448. </xep>