<?xml version="1.0" encoding="US-ASCII" ?>

<!DOCTYPE rfc SYSTEM "rfc2629.dtd">

<?rfc toc="yes" ?>
<?rfc compact="yes" ?>
<?rfc subcompact="no" ?>
<?rfc symrefs="yes" ?>
<?rfc sortrefs="yes" ?>
<?rfc rfcedstyle="yes" ?>

<rfc submissionType="IETF" ipr="pre5378Trust200902" number="6856"
    category="std" consensus="yes"  obsoletes="5721">
<front>
<title abbrev="POP3 Support for UTF-8">Post Office Protocol Version 3 (POP3) Support for UTF-8</title>

 <author fullname="Randall Gellens" initials="R" 
            surname="Gellens">
      <organization>QUALCOMM Incorporated</organization>

      <address>
         <postal> <street>5775 Morehouse Drive</street>
            <city>San Diego</city>
            <region>CA</region><code>92651</code><country>USA</country></postal>

        <email>rg+ietf@qualcomm.com</email>
      </address>
    </author>

 <author fullname="Chris Newman" initials="C" 
            surname="Newman">
      <organization>Oracle</organization>

      <address>
         <postal> <street>800 Royal Oaks</street>
            <city>Monrovia</city>
            <region>CA</region><code>91016-6347</code><country>USA</country></postal>
        <email>chris.newman@oracle.com</email>
      </address>
    </author>
	
	<author initials="J." surname="Yao" fullname="Jiankang YAO">
      <organization>CNNIC</organization>
      <address>
         <postal>
            <street>No.4 South 4th Street, Zhongguancun</street>
            <city>Beijing</city><country>China</country>
           </postal>
         <phone>+86 10 58813007 </phone>
         <email>yaojk@cnnic.cn</email>
      </address>
  </author>
  
  	<author initials="K." surname="Fujiwara" fullname="Kazunori Fujiwara">
      <organization abbrev="JPRS">Japan Registry Services Co., Ltd.</organization>
      <address>
         <postal>
            <street>Chiyoda First Bldg. East 13F, 3-8-1 Nishi-Kanda</street>
            <city>Tokyo</city><country>Japan</country>
           </postal>
         <phone>+81 3 5215 8451</phone>
         <email>fujiwara@jprs.co.jp</email>
      </address>
  </author>


<date month="January" year="2013" />




<abstract><t> 
This specification extends the Post Office Protocol
version 3 (POP3) to support international strings encoded in UTF-8 in
usernames, passwords, mail addresses, message headers, and
protocol-level text strings.

</t></abstract>
</front>
<middle>

<section title="Introduction">
<t>This document forms part of the Email Address Internationalization
 protocols described in the <xref target="RFC6530">Email Address Internationalization Framework
document</xref>.  As
part of the overall Email Address Internationalization work, email messages can be transmitted and
delivered containing a Unicode string encoded in UTF-8 in the header and/or body, 
and maildrops that
are accessed using <xref target="RFC1939">POP3</xref> might natively
store UTF-8.</t>



<t>This specification extends <xref target="RFC1939">POP3</xref>
using the
<xref target="RFC2449">POP3 extension mechanism</xref> to
permit un-encoded <xref target="RFC3629">UTF-8</xref> in headers 
and bodies (e.g., transferred using 8-bit content-transfer-encoding)
as
described in <xref target="RFC6532">"Internationalized Email
  Headers"</xref>.  


  
 It also adds a mechanism to support login names and passwords
 containing a UTF-8 string, a mechanism to support UTF-8 
 strings in protocol-level response strings, and the ability to 
 negotiate a language for such response strings.</t>


<t>This specification also adds a new response code to
   indicate that a message was not delivered
   because it required UTF-8 mode (as discussed in <xref target="UTF8Capability" />) and the
   server was unable or unwilling to create and deliver a
   variant form of the message as
discussed in Section 7 of  <xref target="RFC6855"/>.</t>


 <t> 
 This specification replaces an earlier, experimental, approach to the
 same problem <xref target="RFC5721"></xref>.</t>
 

<section title="Conventions Used in This Document">
<t>The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
"SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in
this document are to be interpreted as described in 
<xref target="RFC2119">"Key words for use in RFCs to Indicate
Requirement Levels"</xref>.</t>


<t>The terms "UTF-8 string" or "UTF-8 character" are used to refer to
   Unicode characters, which may or may not be members of the ASCII
   subset, in UTF-8 <xref target="RFC3629"></xref>, a standard Unicode encoding form.  All
   other specialized terms used in this specification are defined in the Email Address Internationalization
   framework document.</t> 

<t>In examples, "C:" and "S:" indicate lines sent by the client and
server, respectively.  If a single "C:" or "S:" label applies to multiple
lines, then the line breaks between those lines are for editorial
clarity only and are not part of the actual protocol exchange.</t>

<t>Note that examples always use ASCII characters due to
  limitations of the RFC document format; otherwise, some examples
  for the "LANG" command may appear incorrectly.</t>
</section></section>


<section anchor="UTF8Capability" title="&quot;UTF8&quot; Capability">
<t>This specification adds a new POP3 Extension <xref target="RFC2449"></xref>
   capability response tag and command to specify support for
   header field information in UTF-8 rather than only ASCII.  
   The capability tag and
   new command and functionality are described below.  
  </t>

<t><list style="hanging">
<t hangText="CAPA tag:"><vspace/>UTF8</t>
<t hangText="Arguments with CAPA tag:"><vspace/>USER</t>
<t hangText="Added Commands:"><vspace/>UTF8</t>
<t hangText="Standard commands affected:"><vspace/>USER, PASS, APOP, LIST, TOP, RETR</t>
<t hangText="Announced states / possible differences:"><vspace/>both / no</t>
<t hangText="Commands valid in states:"><vspace/>AUTHORIZATION</t>
<t hangText="Specification reference:"><vspace/>this document</t>
<t hangText="Discussion:"><vspace/></t>

</list>
</t>
<t>This capability adds the "UTF8" command to POP3. The
"UTF8" command switches the session from the ASCII-only mode of <xref target="RFC1939" />
to UTF-8 mode. The UTF-8 mode means that, all messages
transmitted between servers and clients are UTF-8 strings, and
both servers and clients can send and accept UTF-8 string.</t>

<section anchor="UTF8_Command" title="The &quot;UTF8&quot; Command">
<t>The "UTF8" command enables UTF-8 mode.  The "UTF8" command has no parameters.</t>

<t>
UTF-8
mode has no effect on messages in an ASCII-only maildrop. 

   Messages in native UTF-8 maildrops can be encoded in either (or both)
   UTF-8 using internationalized headers <xref target="RFC6532"/> or 8bit
   content-transfer-encoding (see Section 2.8 of <xref target="RFC2045"/>),
   or they can be encoded in ASCII.


The message at maildrops
can be encoded in ASCII, UTF-8, or something else. 

In UTF-8 mode,
if the character encoding format of maildrops is UTF-8 or ASCII, the messages are sent to the client as is; if the character encoding format of maildrops is a format other than
UTF-8 or ASCII, the messages' encoding format SHOULD be converted to be UTF-8 before they are sent to the client.

 When UTF-8 mode has not been enabled, non-ASCII strings MUST NOT be
   sent to the client as is.

    If a client requests a UTF-8 message when
   UTF-8 mode is not enabled, the server MUST either send the client
   a surrogate message that complies with unextended POP and
   Internet Mail Format without UTF-8 mode support, or fail the request
   with an -ERR response.
 
 
 See <xref target="RFC6855"/>, Section 7, for information about creating a
   surrogate message, and for a discussion of potential issues.

 <xref target="UTF8RC" /> of this document discusses "UTF8"
 response codes.


The server MAY respond to the "UTF8" command with an
   -ERR response.</t>




<t>  
  Note that even in UTF-8 mode, MIME binary
content-transfer-encoding as defined in Section 6.2 of
<xref target="RFC2045"/> is still not permitted.  MIME 8bit
content-transfer-encoding (8BITMIME) <xref target="RFC6152"/> is
obviously allowed.

  
  </t>

<t>The octet count (size) of a message reported in a response to
the LIST command SHOULD match the actual number of octets sent in a
RETR response (not counting byte-stuffing).  Sizes reported elsewhere,
  such as in STAT responses and non-standardized, free-form text in
  positive status indicators (following "+OK") need not be accurate,
  but it is preferable if they are.</t>
<t>
	
	Normal operation for
maildrops that natively support non-ASCII characters
will be for both
	servers and clients to support the extension discussed in
	this specification.  Upgrading both clients and servers
	is the only fully satisfactory way to support the
	capabilities offered by the "UTF8" extension and SMTPUTF8
	mail more generally.  Servers must, however, anticipate the
	possibility of a client attempting to access a message that
	requires this extension without having issued the "UTF8"
	command.  There are no completely satisfactory responses
	for this case other than upgrading the client to support
	this specification.  One solution, unsatisfactory because
	the user may be confused by being able to access the
	message through some means and not others, is that a server
	MAY choose to reject the command to retrieve the message as
	discussed in <xref target="UTF8RC" />.  Other alternatives, including the
	possibility of creating and delivering a variant form of the
	message, are discussed in Section 7 of  <xref target="RFC6855"/>.</t>

<t>Clients MUST NOT issue the <xref target="RFC2595">STLS
command</xref> after issuing UTF8; servers MAY (but are not required
to) enforce this by rejecting with an -ERR response an STLS command
issued subsequent to a successful "UTF8" command.  (Because this is a
protocol error as opposed to a failure based on conditions,
an <xref target="RFC2449">extended response code</xref> is not
specified.)</t>

</section>


<section title="USER Argument to &quot;UTF8&quot; Capability">
<t>If the USER argument is included with this capability, it indicates
that the server accepts UTF-8 usernames and passwords.</t>

<t>Servers that include the USER argument in the "UTF8" capability
  response SHOULD apply <xref target="RFC4013">SASLprep</xref> or one of its successors from the Standards
   Track to the
  arguments of the USER and PASS commands.</t>

<t>A client or server that supports APOP and permits UTF-8 in usernames or passwords MUST apply <xref target="RFC4013">SASLprep</xref>
or one of its successors from the Standards Track
to the username and password used to compute the APOP digest.</t>

<t>When applying SASLprep <xref target="RFC4013"/>, servers MUST reject UTF-8 usernames or passwords that contain a UTF-8 character listed in
  Section 2.3 of SASLprep.
  When applying SASLprep to the USER argument, the PASS argument,
  or the APOP username argument, a compliant server or client MUST
  treat them as a query string <xref target="RFC3454"/>. When applying SASLprep to the APOP password argument, a
  compliant server or client MUST treat them as a stored string <xref target="RFC3454"/>.</t>


<t>The client does not need to issue the "UTF8" command prior to using UTF-8 in authentication.  However, clients MUST NOT use the UTF-8 string in USER, PASS, or APOP commands unless the USER argument is included in the "UTF8" capability response.</t>
<t>The server MUST reject UTF-8 usernames or passwords that fail to
  comply with the formal syntax
  in <xref target="RFC3629">UTF-8</xref>.</t>

<t>Use of UTF-8 string in the AUTH command is governed by
  the <xref target="RFC5034">POP3 SASL</xref> mechanism.</t>

</section>

</section>


<?rfc needLines="8"?>
<section title="&quot;LANG&quot; Capability">
<t>This
  document adds a new POP3 extension <xref target="RFC2449"></xref> capability response tag to indicate support for
  a new command: LANG.  The capability tag and new command are
  described below.</t>





<t><list style="hanging">
<t hangText="CAPA tag:"><vspace/>LANG</t>
<t hangText="Arguments with CAPA tag:"><vspace/>none</t>
<t hangText="Added Commands:"><vspace/>LANG</t>
<t hangText="Standard commands affected:"><vspace/>All</t>
<t hangText="Announced states / possible differences:"><vspace/>both / no</t>
<t hangText="Commands valid in states:"><vspace/>AUTHORIZATION, TRANSACTION</t>
<t hangText="Specification reference:"><vspace/>this document</t>
<t hangText="Discussion:"><vspace/></t>

</list>
</t>
<t>POP3 allows most +OK and -ERR server responses to include
human-readable text that, in some cases, might be presented to the
user.  But that text is limited to ASCII by the <xref
target="RFC1939">POP3 specification</xref>.  The "LANG" capability and
command permit a POP3 client to negotiate which language the server
uses when sending human-readable text.</t>
    

<t>The "LANG" command requests that human-readable text included in all
subsequent +OK and -ERR responses be localized to a language matching
the language range argument (the "basic language range" as described by
<xref target="RFC4647"></xref>).  If the command succeeds, the server returns an
+OK response followed by a single space, the exact language tag
selected, and another space. Human-readable text in the
appropriate language then appears in the rest of the line. This, and subsequent protocol-level
human-readable text, is encoded in the UTF-8 charset.</t>

<t>If the command fails, the server returns an -ERR response and
subsequent human-readable response text continues to use the language
that was previously used.</t>

<t>If the client issues a "LANG" command with the special "*"
language range argument, it indicates a request
to use a language designated as preferred by the server administrator.  
The preferred language MAY vary based on the currently active user.</t>

<t>If no argument is given and the POP3 server issues a positive
  response, that response will usually consist of multi-lines.  After the initial
  +OK, for each language tag the server supports, the POP3 server
  responds with a line for that language.  This line is called a
  "language listing".</t>

<t>In order to simplify parsing, all POP3 servers are required to use
  a certain format for language listings.  A language listing consists
  of the <xref target="RFC5646">language tag</xref> of the message, optionally
  followed by a single space and a human-readable description of the
  language in the language itself, using the UTF-8 charset. There is no specific order listing of languages, which may
  depend on configuration or implementation.</t>



<figure>
<preamble>Examples for "LANG" capability usage are shown below:</preamble>
<artwork><![CDATA[
   Note that some examples do not include the correct character
   accents due to limitations of the RFC document format. 

    
   C: USER karen
   S: +OK Hello, karen
   C: PASS password 
   S: +OK karen's maildrop contains 2 messages (320 octets)

   Client requests deprecated MUL language.  Server replies
   with -ERR response.
    
   C: LANG MUL 
   S: -ERR invalid language MUL
    
   A LANG command with no parameters is a request for
   a language listing.
    
   C: LANG
   S: +OK Language listing follows:
   S: en English
   S: en-boont English Boontling dialect
   S: de Deutsch
   S: it Italiano
   S: es Espanol
   S: sv Svenska
   S: .
    
   A request for a language listing might fail.

   C: LANG
   S: -ERR Server is unable to list languages
    
   Once the client selects the language, all responses will be in 
   that language, starting with the response to the "LANG" command.
    
   C: LANG es 
   S: +OK es Idioma cambiado
    
   If a server returns an -ERR response to a "LANG" command
   that specifies a primary language, the current language
   for responses remains in effect.
    
   C: LANG uga 
   S: -ERR es Idioma <<UGA>> no es conocido
   
   C: LANG sv
   S: +OK sv Kommandot "LANG" lyckades
   
   C: LANG *
   S: +OK es Idioma cambiado
]]></artwork>
</figure>
</section>

<section title="Non-ASCII Character Maildrops">
<t>When a POP3 server uses a native non-ASCII character maildrop, it is the responsibility
of the server to comply with the <xref target="RFC1939">POP3 base
specification</xref> and <xref target="RFC5322">Internet Message
    Format</xref> when not in UTF-8 mode. When the server is not in UTF-8 mode and the message
requires that mode, requests to download the message MAY
be rejected (as specified in the next section) or the
various other alternatives outlined in <xref target="UTF8_Command" /> above, including creation and delivery
of variations on the original message, MAY be considered.
</t>

</section>


<section anchor="UTF8RC" title="&quot;UTF8&quot; Response Code">
<t>Per <xref target="RFC2449">"POP3 Extension Mechanism"</xref>,
  this document adds a new response code: UTF8, described
  below.</t>

<t><list style="hanging">
<t hangText="Complete response code:"><vspace/>UTF8</t>
<t hangText="Valid for responses:"><vspace/>-ERR</t>
<t hangText="Valid for commands:"><vspace/>LIST, TOP, RETR</t>
<t hangText="Response code meaning and expected client behavior:"><vspace/></t>

</list>
</t>
<t> The "UTF8" response code indicates that a failure is due to a
request when not in UTF-8 mode for message content containing a
UTF-8 string.</t>
<t> The client MAY reissue the command after entering UTF-8 mode.</t>

</section>


<?rfc needLines="4"?>
<section title="IANA Considerations">
<t>Section 2 and 3 of this specification update two capabilities ("UTF8" and "LANG") to
the <xref target="RFC2449">POP3 capability registry</xref>.</t>
<t>Section 5 of this specification adds one new response code ("UTF8") to
the <xref target="RFC2449">POP3 response codes registry</xref>.</t>
</section>

<section title="Security Considerations">
<t>The security considerations of <xref target="RFC3629">UTF-8</xref>,
<xref target="RFC4013">SASLprep</xref>, and the <xref target="RFC5198">Unicode Format for Network Interchange</xref>  apply to this specification,
particularly with respect to use of UTF-8 in usernames and passwords.</t>

<t>The "LANG *" command might reveal the existence and preferred
language of a user to an active attacker probing the system if the
active language changes in response to the USER, PASS, or APOP
commands prior to validating the user's credentials.  Servers are strongly advised to
implement a configuration to prevent this exposure.</t>

<t>It is possible for a man-in-the-middle attacker to insert a "LANG"
  command in the command stream, thus, making protocol-level diagnostic
  responses unintelligible to the user. 


 
  A mechanism to protect the
   integrity of the session can be used to defeat such attacks.  For example,
   a client can issue the STLS command <xref target="RFC2595"/> before issuing the "LANG"
   command.

  </t>

<t>As with other internationalization upgrades, modifications
	to server authentication code (in this case, to support
	non-ASCII strings) needs to be done with care to avoid
	introducing vulnerabilities (for example, in string parsing
	or matching). This is particularly important if the native
	databases or mailstore of the operating system use some
	character set or encoding other than Unicode in UTF-8.</t>


</section>


</middle>
<back>


<references title="Normative References">
<?rfc include="reference.RFC.1939"?> <!-- POP3 -->
<?rfc include="reference.RFC.2045"?> <!-- MIME Bodies -->
<?rfc include="reference.RFC.2047"?> <!-- MIME Headers -->
<?rfc include="reference.RFC.2119"?> <!-- Keywords -->

<?rfc include="reference.RFC.2449"?> <!-- POP3 CAPA -->
<?rfc include="reference.RFC.5322"?> <!-- Message Format -->
<?rfc include="reference.RFC.5646"?> <!-- language tags -->
<?rfc include="reference.RFC.4647"?> <!-- language range -->
<?rfc include="reference.RFC.3629"?> <!-- UTF-8 -->
<?rfc include="reference.RFC.4013"?> <!-- SASLprep -->
<?rfc include="reference.RFC.3454"?> <!-- Stringprep -->

<?rfc include="reference.RFC.6530" ?>
<?rfc include="reference.RFC.6532" ?>
<?rfc include="reference.RFC.5198" ?>
 <?rfc include="reference.RFC.6152" ?>

<!--I-D.ietf-eai-5738bis; companion doc -->

<reference anchor="RFC6855">
 <front> <title>IMAP Support for UTF-8</title> 
 <author fullname="Pete Resnick" surname="Resnick" initials="P"> 
 <organization/> </author> 
 <author fullname="Chris Newman" surname="Newman" initials="C"> <organization/> </author>
<author fullname="Sean Shen" surname="Shen" initials="S"> <organization/> </author> 
<date year="2013" month="January"/> 
<abstract><t>This specification extends the Internet Message Access Protocol version 4rev1 
(IMAP4rev1) to support UTF-8 encoded international string in usernames, mail addresses
 and message headers. This specification replaces RFC 5738.</t></abstract> </front>
 <seriesInfo value="RFC" name="6855"/>
 </reference>


</references>
<references title="Informative References">
<?rfc include="reference.RFC.2595"?> <!-- IMAP/POP/ACAP TLS -->

<?rfc include="reference.RFC.5034"?> <!-- POP3 SASL -->

<?rfc include="reference.RFC.2231"?>






<?rfc include="reference.RFC.5721"?> <!-- pop exp. -->
</references>
<section title="Design Rationale">
<t>This non-normative section discusses the reasons behind some of the
  design choices in this specification.</t>

<t>Due to interoperability problems with <xref target="RFC2047" /> and limited
  deployment of <xref target="RFC2231" />, it is hoped these 7-bit encoding mechanisms
  can be deprecated in the future when UTF-8 header support becomes
  prevalent. </t>

<t>The USER capability (Section 2.2) and hence the upgraded USER
	command  and additional support for non-ASCII credentials, are
	optional because the implementation burden
  of <xref target="RFC4013">SASLprep</xref> is not well understood, and
  mandating such support in all cases could negatively impact
  deployment.</t>



</section>
<section title="Acknowledgments">
<t>Thanks to John Klensin, Joseph Yee, Tony Hansen, Alexey Melnikov, and other Email Address Internationalization
working group participants who provided helpful suggestions and
interesting debate that improved this specification.</t>
</section>
</back>
</rfc>
