<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type='text/xsl' href='xep.xsl'?>
<xep xmlns="">
<header>
  <title>File metadata element</title>
  <abstract>This specification defines a generic file metadata element to be used in other specifications.</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>0446</number>
  <status>Experimental</status>
  <type>Standards Track</type>
  <sig>Standards</sig>
  <approver>Council</approver>
  <dependencies>
    <spec>XMPP Core</spec>
    <spec>XEP-0001</spec>
    <spec>XEP-0082</spec>
    <spec>XEP-0264</spec>
    <spec>XEP-0300</spec>
  </dependencies>
  <supersedes/>
  <supersededby/>
  <shortname>file-metadata</shortname>
  
  <author>
    <firstname>Marvin</firstname>
    <surname>Wißfeld</surname>
    <email>xmpp@larma.de</email>
    <jid>jabber@larma.de</jid>
  </author>

  <revision>
    <version>0.2.0</version>
    <date>2022-07-17</date>
    <initials>lmw</initials>
    <remark>Use height/width instead of dimensions</remark>
  </revision>
  <revision>
    <version>0.1.0</version>
    <date>2020-11-24</date>
    <initials>XEP Editor (jsc)</initials>
    <remark>Accepted by vote of Council on 2020-11-18.</remark>
  </revision>
  <revision>
    <version>0.0.1</version>
    <date>2020-11-03</date>
    <initials>lmw</initials>
    <remark><p>First draft.</p></remark>
  </revision>
</header>
<section1 topic="Introduction" anchor="intro">
  <p>
    Several existing specification have the need to provide metadata on a file.
    The only specification of an element that contains file metadata so far is
    provided as part of <span class="ref"><link url="https://xmpp.org/extensions/xep-0234.html">Jingle File Transfer (XEP-0234)</link></span> <note>XEP-0234: Jingle File Transfer &lt;<link url="https://xmpp.org/extensions/xep-0234.html">https://xmpp.org/extensions/xep-0234.html</link>&gt;.</note>. This resulted in the situation that XEPs like
    <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> depend on the mostly unrelated <span class="ref"><link url="https://xmpp.org/extensions/xep-0166.html">Jingle (XEP-0166)</link></span> <note>XEP-0166: Jingle &lt;<link url="https://xmpp.org/extensions/xep-0166.html">https://xmpp.org/extensions/xep-0166.html</link>&gt;.</note> just for the metadata
    element. The motiviation of this XEP is to get rid of such dependencies and
    have a dedicated place to define a file metadata element.
  </p>
</section1>
<section1 topic="Element format" anchor="format">
  <code><![CDATA[
<file xmlns='urn:xmpp:file:metadata:0'>
    <media-type>text/plain</media-type>
    <name>test.txt</name>
    <date>2015-07-26T21:46:00+01:00</date>
    <size>6144</size>
    <hash xmlns='urn:xmpp:hashes:2'
          algo='sha-1'>w0mcJylzCn+AfvuGdqkty2+KP48=</hash>
</file>]]></code>
  <p>The child elements of the &lt;file/&gt; element are as follows:</p>
  <table caption="File Description Elements">
    <tr>
      <th>Element Name</th>
      <th>Description</th>
      <th>Example</th>
    </tr>
    <tr>
      <td>date</td>
      <td>Timestamp specifying the last modified time of the file (which MUST conform to the DateTime profile of <span class="ref"><link url="https://xmpp.org/extensions/xep-0082.html">XMPP Date and Time Profiles (XEP-0082)</link></span> <note>XEP-0082: XMPP Date and Time Profiles &lt;<link url="https://xmpp.org/extensions/xep-0082.html">https://xmpp.org/extensions/xep-0082.html</link>&gt;.</note>).</td>
      <td><tt>2015-07-26T21:46:00+01:00</tt></td>
    </tr>
    <tr>
      <td>desc</td>
      <td>A human readable description of the file. Multiple <tt>&lt;desc/&gt;</tt> elements MAY be included if different xml:lang values are specified.</td>
      <td><tt>Picture of 24th XSF Summit</tt></td>
    </tr>
    <tr>
      <td>hash</td>
      <td>A hash of the file content, using the <tt>&lt;hash/&gt;</tt> element defined in <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> and qualifed by the 'urn:xmpp:hashes:2' namespace. Multiple hashes MAY be included for hash agility.</td>
      <td><em>see specification</em></td>
    </tr>
    <tr>
      <td>height</td>
      <td>Vertical dimensions of image or video files, in pixels.</td>
      <td><tt>1920</tt></td>
    </tr>
    <tr>
      <td>length</td>
      <td>Length of an audio or video file, in milliseconds.</td>
      <td><tt>63000</tt></td>
    </tr>
    <tr>
      <td>media-type</td>
      <td>The media type of the file content, which SHOULD be a valid MIME-TYPE as registered with the <span class="ref"><link url="http://www.iana.org/">Internet Assigned Numbers Authority (IANA)</link></span> <note>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 &lt;<link url="http://www.iana.org/">http://www.iana.org/</link>&gt;.</note> (specifically, as listed at &lt;<link url="http://www.iana.org/assignments/media-types">http://www.iana.org/assignments/media-types</link>&gt;). If not specified, the content is assumed to be "application/octet-stream".</td>
      <td><tt>text/plain</tt></td>
    </tr>
    <tr>
      <td>name</td>
      <td>The name of the file. The name SHOULD NOT contain characters or character sequences that would be interpreted as a directory structure by the local file system (e.g. "/", "\", "../", etc.). If any such characters or character sequences are present (possibly because the local and remote file systems use different syntax for directory structure), they SHOULD be escaped (e.g., via percent-encoding) before using the name as part of any file system operation. See <link url="#security">Security Considerations</link>.</td>
      <td><tt>text.txt</tt></td>
    </tr>
    <tr>
      <td>size</td>
      <td>The length of the file's content, in bytes.</td>
      <td><tt>6144</tt></td>
    </tr>
    <tr>
      <td>thumbnail</td>
      <td>A thumbnail element of the file, using the &lt;thumbnail/&gt; element defined in <span class="ref"><link url="https://xmpp.org/extensions/xep-0264.html">File Transfer Thumbnails (XEP-0264)</link></span> <note>XEP-0264: File Transfer Thumbnails &lt;<link url="https://xmpp.org/extensions/xep-0264.html">https://xmpp.org/extensions/xep-0264.html</link>&gt;.</note> and qualified by the 'urn:xmpp:thumbs:1' namespace. Multiple thumbnails MAY be included for media type and size agility.</td>
      <td><em>see specification</em></td>
    </tr>
    <tr>
      <td>width</td>
      <td>Horizontal dimensions of image or video files, in pixels.</td>
      <td><tt>1080</tt></td>
    </tr>
  </table>
  <p>
    All child elements are OPTIONAL, however, specifications making use of the
    file metadata object MAY require providing some of these elements as part
    of their specification.
  </p>
</section1>
<section1 topic="Security Considerations" anchor="security">
  <p>
    Caution needs to be exercised when using the <tt>&lt;name/&gt;</tt> of the metadata
    to control any interaction with a file system. For example, a malicious
    user could request a file with <tt>&lt;name&gt;/etc/passwd&lt;/name&gt;</tt> or
    include file system specific control patterns such as
    <tt>&lt;name&gt;../../private.txt&lt;/name&gt;</tt> to try and access a sensitive
    file outside of the set of files intended to be shared. Or a malicious user
    could offer a file named <tt>/etc/passwd</tt> to try and trick the receiver into
    overwriting that or other sensitive files. Therefore, implementations
    SHOULD escape any file system path separators in the <tt>&lt;name/&gt;</tt> before
    using that value in any file system calls.
  </p>
  <p>
    It is RECOMMENDED for implementations to use the strongest hashing
    algorithm available to both parties. See <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> for further discussion.
  </p>
</section1>
<section1 topic="IANA Considerations" anchor="iana">
  <p>This document requires no interaction with the <span class="ref"><link url="http://www.iana.org/">Internet Assigned Numbers Authority (IANA)</link></span> <note>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 &lt;<link url="http://www.iana.org/">http://www.iana.org/</link>&gt;.</note>.</p>
</section1>
<section1 topic="XMPP Registrar Considerations" anchor="registrar">
  <section2 topic="Protocol Namespaces" anchor="ns">
    <p>The <span class="ref"><link url="https://xmpp.org/registrar/">XMPP Registrar</link></span> <note>The XMPP Registrar maintains a list of reserved protocol namespaces as well as registries of parameters used in the context of XMPP extension protocols approved by the XMPP Standards Foundation. For further information, see &lt;<link url="https://xmpp.org/registrar/">https://xmpp.org/registrar/</link>&gt;.</note> includes 'urn:xmpp:file:metadata:0' in its registry of protocol namespaces (see &lt;<link url="https://xmpp.org/registrar/namespaces.html">https://xmpp.org/registrar/namespaces.html</link>&gt;).</p>
    <ul>
      <li>urn:xmpp:file:metadata:0</li>
    </ul>
  </section2>
</section1>
<section1 topic="Acknowledgements" anchor="ack">
  <p>Thanks to the authors of <span class="ref"><link url="https://xmpp.org/extensions/xep-0234.html">Jingle File Transfer (XEP-0234)</link></span> <note>XEP-0234: Jingle File Transfer &lt;<link url="https://xmpp.org/extensions/xep-0234.html">https://xmpp.org/extensions/xep-0234.html</link>&gt;.</note> which heavily inspired this XEP.</p>
</section1>
</xep>
