<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type='text/xsl' href='xep.xsl'?>
<xep xmlns="">
    <header>
        <title>Emoji Markup</title>
        <abstract>This specification leverages <span class="ref"><link url="https://xmpp.org/extensions/xep-0394.html">Message Markup (XEP-0394)</link></span> <note>XEP-0394: Message Markup &lt;<link url="https://xmpp.org/extensions/xep-0394.html">https://xmpp.org/extensions/xep-0394.html</link>&gt;.</note> and <span class="ref"><link url="https://xmpp.org/extensions/xep-0447.html">Stateless file sharing (XEP-0447)</link></span> <note>XEP-0447: Stateless file sharing &lt;<link url="https://xmpp.org/extensions/xep-0447.html">https://xmpp.org/extensions/xep-0447.html</link>&gt;.</note> (or <span class="ref"><link url="https://xmpp.org/extensions/xep-0385.html">Stateless Inline Media Sharing (XEP-0385)</link></span> <note>XEP-0385: Stateless Inline Media Sharing (SIMS) &lt;<link url="https://xmpp.org/extensions/xep-0385.html">https://xmpp.org/extensions/xep-0385.html</link>&gt;.</note>) to send custom emojis</abstract>
            
<legal>
<copyright>This XMPP Extension Protocol is copyright © 1999 – 2024 by the <link url="https://xmpp.org/">XMPP Standards Foundation</link> (XSF).</copyright>
<permissions>Permission is hereby granted, free of charge, to any person obtaining a copy of this specification (the "Specification"), to make use of the Specification without restriction, including without limitation the rights to implement the Specification in a software program, deploy the Specification in a network service, and copy, modify, merge, publish, translate, distribute, sublicense, or sell copies of the Specification, and to permit persons to whom the Specification is furnished to do so, subject to the condition that the foregoing copyright notice and this permission notice shall be included in all copies or substantial portions of the Specification. Unless separate permission is granted, modified works that are redistributed shall not contain misleading information regarding the authors, title, number, or publisher of the Specification, and shall not claim endorsement of the modified works by the authors, any organization or project to which the authors belong, or the XMPP Standards Foundation.</permissions>
<warranty>## NOTE WELL: This Specification is provided on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. ##</warranty>
<liability>In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall the XMPP Standards Foundation or any author of this Specification be liable for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising from, out of, or in connection with the Specification or the implementation, deployment, or other use of the Specification (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if the XMPP Standards Foundation or such author has been advised of the possibility of such damages.</liability>
<conformance>This XMPP Extension Protocol has been contributed in full conformance with the XSF's Intellectual Property Rights Policy (a copy of which can be found at &lt;<link url="https://xmpp.org/about/xsf/ipr-policy">https://xmpp.org/about/xsf/ipr-policy</link>&gt; or obtained by writing to XMPP Standards Foundation, P.O. Box 787, Parker, CO 80134 USA).</conformance>
</legal>
        <number>xxxx</number>
        <status>ProtoXEP</status>
        <type>Standards Track</type>
        <sig>Standards</sig>
        <approver>Council</approver>
        <dependencies>
            <spec>XMPP Core</spec>
            <spec>XEP-0001</spec>
            <spec>XEP-0030</spec>
            <spec>XEP-0115</spec>
            <spec>XEP-0300</spec>
            <spec>XEP-0385</spec>
            <spec>XEP-0394</spec>
            <spec>XEP-0447</spec>
        </dependencies>
        <supersedes/>
        <supersededby/>
        <shortname>NOT_YET_ASSIGNED</shortname>
        <tags>
            <tag>markup</tag>
        </tags>
        <author>
            <firstname>Snit</firstname>
            <surname>Guckfung</surname>
            <email>snit@cock.li</email>
            <jid>snit@isekai.rocks</jid>
        </author>
        <author>
            <firstname>Sigrid</firstname>
            <surname>Einarsson</surname>
            <email>techmetx11@disroot.org</email>
            <jid>techmetx11@disroot.org</jid>
        </author>
        <revision>
            <version>0.0.3</version>
            <date>2026-04-05</date>
            <initials>techmetx11</initials>
            <remark><p>Changed the id attribute to refer to the first hash of the media element. Removed packs</p></remark>
        </revision>
        <revision>
            <version>0.0.2</version>
            <date>2026-04-04</date>
            <initials>techmetx11</initials>
            <remark><p>Added emoji packs, and switched to using SFS instead of just BoB</p></remark>
        </revision>
        <revision>
            <version>0.0.1</version>
            <date>2026-03-08</date>
            <initials>snit</initials>
            <remark><p>First draft.</p></remark>
        </revision>
    </header>
    <section1 topic="Introduction" anchor="intro">
        <p>Many legacy platforms allow users to create and send custom emojis in place of the ones supported by Unicode, allowing users a wider range of expression when chatting. This specification provides a way for users to send custom emojis using a custom <span class="ref"><link url="https://xmpp.org/extensions/xep-0394.html">Message Markup (XEP-0394)</link></span> <note>XEP-0394: Message Markup &lt;<link url="https://xmpp.org/extensions/xep-0394.html">https://xmpp.org/extensions/xep-0394.html</link>&gt;.</note> element containing <span class="ref"><link url="https://xmpp.org/extensions/xep-0231.html">Bits of Binary (XEP-0231)</link></span> <note>XEP-0231: Bits of Binary &lt;<link url="https://xmpp.org/extensions/xep-0231.html">https://xmpp.org/extensions/xep-0231.html</link>&gt;.</note> data.</p>
    </section1>

    <section1 topic="Discovering Support" anchor="disco">
        <p>Implementations which support custom emoji markup MUST advertise 'urn:xmpp:markup:emoji:0' via <span class="ref"><link url="https://xmpp.org/extensions/xep-0115.html">Entity Capabilities (XEP-0115)</link></span> <note>XEP-0115: Entity Capabilities &lt;<link url="https://xmpp.org/extensions/xep-0115.html">https://xmpp.org/extensions/xep-0115.html</link>&gt;.</note> and <span class="ref"><link url="https://xmpp.org/extensions/xep-0030.html">Service Discovery (XEP-0030)</link></span> <note>XEP-0030: Service Discovery &lt;<link url="https://xmpp.org/extensions/xep-0030.html">https://xmpp.org/extensions/xep-0030.html</link>&gt;.</note>.</p>
    </section1>

    <section1 topic="Use Cases" anchor="usecases">
        <p>To send a custom emoji, implementations use a custom &lt;emoji /&gt; element qualified with the 'urn:xmpp:markup:emoji:0' namespace inside a <span class="ref"><link url="https://xmpp.org/extensions/xep-0394.html">Message Markup (XEP-0394)</link></span> <note>XEP-0394: Message Markup &lt;<link url="https://xmpp.org/extensions/xep-0394.html">https://xmpp.org/extensions/xep-0394.html</link>&gt;.</note> &lt;span /&gt; element as a child of a <span class="ref"><link url="https://xmpp.org/extensions/xep-0394.html">Message Markup (XEP-0394)</link></span> <note>XEP-0394: Message Markup &lt;<link url="https://xmpp.org/extensions/xep-0394.html">https://xmpp.org/extensions/xep-0394.html</link>&gt;.</note> &lt;markup /&gt; element, with a media element (either <span class="ref"><link url="https://xmpp.org/extensions/xep-0447.html">Stateless file sharing (XEP-0447)</link></span> <note>XEP-0447: Stateless file sharing &lt;<link url="https://xmpp.org/extensions/xep-0447.html">https://xmpp.org/extensions/xep-0447.html</link>&gt;.</note> &lt;file-sharing /&gt; or <span class="ref"><link url="https://xmpp.org/extensions/xep-0385.html">Stateless Inline Media Sharing (XEP-0385)</link></span> <note>XEP-0385: Stateless Inline Media Sharing (SIMS) &lt;<link url="https://xmpp.org/extensions/xep-0385.html">https://xmpp.org/extensions/xep-0385.html</link>&gt;.</note> &lt;media-sharing /&gt;) as a sibling of the &lt;markup /&gt; element. The &lt;span /&gt; MUST contain a 'start' and 'end' range which marks the range of text to replace with the custom emoji. If the 'start' and 'end' contain the same index, the emoji MUST be inserted at that index without replacing any text. The &lt;emoji /&gt; MAY contain a 'name' attribute containing the name of the emoji, but it MUST include one or more <span class="ref"><link url="https://xmpp.org/extensions/xep-0300.html">Use of Cryptographic Hash Functions in XMPP (XEP-0300)</link></span> <note>XEP-0300: Use of Cryptographic Hash Functions in XMPP &lt;<link url="https://xmpp.org/extensions/xep-0300.html">https://xmpp.org/extensions/xep-0300.html</link>&gt;.</note> &lt;hash /&gt; elements to identify the specific emoji in one of the media elements.</p>
        <example caption="User sends a custom emoji"><![CDATA[
<message from='romeo@montague.lit' to='juliet@shakespeare.lit' type='chat'>
    <body>To be, or not to be, that is the question 🤔</body>
    <markup xmlns='urn:xmpp:markup:0'>
        <span start='42' end='43'>
            <emoji xmlns='urn:xmpp:markup:emoji:0' name='pondering'>
                <hash xmlns='urn:xmpp:hashes:2' algo='sha3-256'>ENeyvkxcfv8dmL4HBrF3JU1OX1BfpNV3YbhlEb20ReU=</hash>
            </emoji>
        </span>
    </markup>
    <file-sharing xmlns='urn:xmpp:sfs:0'>
        <file xmlns='urn:xmpp:file:metadata:0'>
            <media-type>image/png</media-type>
            <name>pondering</name>
            <size>6129</size>
            <width>64</width>
            <height>64</width>
            <hash xmlns='urn:xmpp:hashes:2' algo='sha3-256'>ENeyvkxcfv8dmL4HBrF3JU1OX1BfpNV3YbhlEb20ReU=</hash>
            <hash xmlns='urn:xmpp:hashes:2' algo='id-blake2b256'>QdJufo3MnaEPCK/2Q8fCiX3FutiQej6uHg5HaCliheY=</hash>
        </file>
        <sources>
            <url-data xmlns='http://jabber.org/protocol/url-data' target='https://download.montague.lit/4a771ac1-f0b2-4a4a-9700-f2a26fa2bb67/pondering.png' />
        </sources>
    </file-sharing>
</message>]]></example>

        <example caption="User sends multiple custom emojis in a message"><![CDATA[
<message from='romeo@montague.lit' to='juliet@shakespeare.lit' type='chat'>
    <body>Look at this funny image I found! :laughing: I wonder what it means? :pondering:</body>
    <markup xmlns='urn:xmpp:markup:0'>
        <span start='34' end='44'>
            <emoji xmlns='urn:xmpp:markup:emoji:0' name='laughing'>
                <hash xmlns='urn:xmpp:hashes:2' algo='sha3-256'>jMbLbIw1lfDhNVrE1wtB8C1R94OXKbyq/i8DUmHiHs8=</hash>
                <hash xmlns='urn:xmpp:hashes:2' algo='id-blake2b256'>a5wIaBMtKT+Rs4TSc0C4ciWb5bmA3GCBv3xIUBxpKGA=</hash>
            </emoji>
        </span>
        <span start='69' end='80'>
            <emoji xmlns='urn:xmpp:markup:emoji:0' name='pondering'>
                <hash xmlns='urn:xmpp:hashes:2' algo='sha3-256'>ENeyvkxcfv8dmL4HBrF3JU1OX1BfpNV3YbhlEb20ReU=</hash>
                <hash xmlns='urn:xmpp:hashes:2' algo='id-blake2b256'>QdJufo3MnaEPCK/2Q8fCiX3FutiQej6uHg5HaCliheY=</hash>
            </emoji>
        </span>
    </markup>
    <file-sharing xmlns='urn:xmpp:sfs:0' id='emoji1'>
        <file xmlns='urn:xmpp:file:metadata:0'>
            <media-type>image/png</media-type>
            <name>laughing</name>
            <size>8391</size>
            <width>64</width>
            <height>64</width>
            <hash xmlns='urn:xmpp:hashes:2' algo='sha3-256'>jMbLbIw1lfDhNVrE1wtB8C1R94OXKbyq/i8DUmHiHs8=</hash>
            <hash xmlns='urn:xmpp:hashes:2' algo='id-blake2b256'>a5wIaBMtKT+Rs4TSc0C4ciWb5bmA3GCBv3xIUBxpKGA=</hash>
        </file>
        <sources>
            <url-data xmlns='http://jabber.org/protocol/url-data' target='https://download.montague.lit/d51e8d71-98a3-4dd7-be64-cb4c778c90d2/laughing.png' />
        </sources>
    </file-sharing>
    <file-sharing xmlns='urn:xmpp:sfs:0' id='emoji2'>
        <file xmlns='urn:xmpp:file:metadata:0'>
            <media-type>image/png</media-type>
            <name>pondering</name>
            <size>6129</size>
            <width>64</width>
            <height>64</width>
            <hash xmlns='urn:xmpp:hashes:2' algo='sha3-256'>ENeyvkxcfv8dmL4HBrF3JU1OX1BfpNV3YbhlEb20ReU=</hash>
            <hash xmlns='urn:xmpp:hashes:2' algo='id-blake2b256'>QdJufo3MnaEPCK/2Q8fCiX3FutiQej6uHg5HaCliheY=</hash>
        </file>
        <sources>
            <url-data xmlns='http://jabber.org/protocol/url-data' target='https://download.montague.lit/16c8bc69-f4b2-4772-8db3-74fca5e2a275/pondering.png' />
        </sources>
    </file-sharing>
</message>]]></example>
    </section1>

    <section1 topic="Business Rules" anchor="rules">
        <p>Many custom emojis can be adequately represented in terms of an existing Unicode emoji. Clients might find it useful to allow users to optionally specify a replacement emoji, which will improve the experience of users of clients which do not support custom emojis, with the name/shortcode of the emoji used only as a fallback. However, this specification makes no recommendation on the fallback text an implementation opts to use.</p>
        <p>Implementations SHOULD expect to handle animated emojis, such as GIFs or animated PNGs. This could include either playing the animation or displaying the first frame.</p>
        <p>Implementations might receive a file type which they do not or cannot support, in which case they MAY opt to ignore the emoji markup altogether.</p>
    </section1>

    <section1 topic="Implementation Notes" anchor="impl">
        <p>Implementations MAY use sticker packs in <span class="ref"><link url="https://xmpp.org/extensions/xep-0449.html">Stickers (XEP-0449)</link></span> <note>XEP-0449: Stickers &lt;<link url="https://xmpp.org/extensions/xep-0449.html">https://xmpp.org/extensions/xep-0449.html</link>&gt;.</note> for emojis too</p>
    </section1>

    <section1 topic="Accessibility Considerations" anchor="access">
        <p>Implementations SHOULD provide a proper fallback for custom emojis, as well as including the 'name' attribute. This helps both users of unsupported clients as well as users who may not be able to view the emoji properly.</p>
        <p>Implementations MAY post-process the file for color deficiency, epilepsy, or other accessiblity reasons. This could include slowing down playback or changing the saturation.</p>
    </section1>

    <section1 topic="Security Considerations" anchor="security">
        <p>Emojis are just media files. All the usual security risks of allowing users to send arbitrary media apply.</p>
    </section1>

    <section1 topic="IANA Considerations" anchor="iana">
        <p>None.</p>
    </section1>

    <section1 topic="XMPP Registrar Considerations" anchor="registrar">
        <p>This specification defines the 'urn:xmpp:markup:emoji:0' namespace.</p>
    </section1>

    <section1 topic="XML Schema" anchor="schema">
        <p>TODO.</p>
    </section1>
</xep>
