📄 rfc5092.txt
字号:
imessagepart = imailbox-ref iuid [isection] [ipartial] ipartial = "/" ipartial-only ipartial-only = ";PARTIAL=" partial-range isection = "/" isection-only isection-only = ";SECTION=" enc-section iserver = [iuserinfo "@"] host [ ":" port ] ; This is the same as "authority" defined ; in [URI-GEN]. See [URI-GEN] for "host" ; and "port" definitions. iuid = "/" iuid-only iuid-only = ";UID=" nz-number ; See [IMAP4] for "nz-number" definition iuserinfo = enc-user [iauth] / [enc-user] iauth ; conforms to the generic syntax of ; "userinfo" as defined in [URI-GEN]. partial-range = number ["." nz-number] ; partial FETCH. The first number is ; the offset of the first byte, ; the second number is the length of ; the fragment. uidvalidity = ";UIDVALIDITY=" nz-number ; See [IMAP4] for "nz-number" definitionMelnikov & Newman Standards Track [Page 20]RFC 5092 IMAP URL Scheme November 200712. IANA Considerations IANA has updated the "imap" definition in the "Uniform Resource Identifier scheme registry" to point to this document. The registration template (as per [URI-REG]) is specified in Section 12.1 of this document.12.1. IANA Registration of imap: URI Scheme This section provides the information required to register the imap: URI scheme. URI scheme name: imap Status: permanent URI scheme syntax: See Section 11 of [RFC5092]. URI scheme semantics: The imap: URI scheme is used to designate IMAP servers, mailboxes, messages, MIME bodies [MIME] and their parts, and search programs on Internet hosts accessible using the IMAP protocol. There is no MIME type associated with this URI. Encoding considerations: See Section 8 of [RFC5092]. Applications/protocols that use this URI scheme name: The imap: URI is intended to be used by applications that might need access to an IMAP mailstore. Such applications may include (but are not limited to) IMAP-capable web browsers; IMAP clients that wish to access a mailbox, message, or edit a message on the server using [CATENATE]; [SUBMIT] clients and servers that are requested to assemble a complete message on submission using [BURL]. Interoperability considerations: A widely deployed IMAP client Netscape Mail (and possibly Mozilla/Thunderbird/Seamonkey) uses a different imap: scheme internally.Melnikov & Newman Standards Track [Page 21]RFC 5092 IMAP URL Scheme November 2007 Security considerations: See Security Considerations (Section 10) of [RFC5092]. Contact: Alexey Melnikov <alexey.melnikov@isode.com> Author/Change controller: IESG References: [RFC5092] and [IMAP4].13. References13.1. Normative References [KEYWORDS] Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, March 1997. [IMAP4] Crispin, M., "INTERNET MESSAGE ACCESS PROTOCOL - VERSION 4rev1", RFC 3501, March 2003. [IMAPABNF] Melnikov, A. and C. Daboo, "Collected Extensions to IMAP4 ABNF", RFC 4466, April 2006. [ABNF] Crocker, D., Ed., and P. Overell, "Augmented BNF for Syntax Specifications: ABNF", RFC 4234, October 2005. [MIME] Freed, N. and N. Borenstein, "Multipurpose Internet Mail Extensions (MIME) Part One: Format of Internet Message Bodies", RFC 2045, November 1996. [URI-GEN] Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform Resource Identifier (URI): Generic Syntax", STD 66, RFC 3986, January 2005. [UTF-8] Yergeau, F., "UTF-8, a transformation format of ISO 10646", STD 63, RFC 3629, November 2003. [NAMESPACE] Gahrns, M. and C. Newman, "IMAP4 Namespace", RFC 2342, May 1998. [LITERAL+] Myers, J., "IMAP4 non-synchronizing literals", RFC 2088, January 1997.Melnikov & Newman Standards Track [Page 22]RFC 5092 IMAP URL Scheme November 2007 [ANONYMOUS] Zeilenga, K., "Anonymous Simple Authentication and Security Layer (SASL) Mechanism", RFC 4505, June 2006. [DATETIME] Klyne, G. and C. Newman, "Date and Time on the Internet: Timestamps", RFC 3339, July 2002. [URLAUTH] Crispin, M., "Internet Message Access Protocol (IMAP) - URLAUTH Extension", RFC 4467, May 2006.13.2. Informative References [SUBMIT] Gellens, R. and J. Klensin, "Message Submission for Mail", RFC 4409, April 2006. [BURL] Newman, C., "Message Submission BURL Extension", RFC 4468, May 2006. [CATENATE] Resnick, P., "Internet Message Access Protocol (IMAP) CATENATE Extension", RFC 4469, April 2006. [SASL] Melnikov, A., Ed., and K. Zeilenga, Ed., "Simple Authentication and Security Layer (SASL)", RFC 4422, June 2006. [GSSAPI] Melnikov, A., Ed., "The Kerberos V5 ("GSSAPI") Simple Authentication and Security Layer (SASL) Mechanism", RFC 4752, November 2006. [DIGEST-MD5] Leach, P. and C. Newman, "Using Digest Authentication as a SASL Mechanism", RFC 2831, May 2000. [URI-REG] Hansen, T., Hardie, T., and L. Masinter, "Guidelines and Registration Procedures for New URI Schemes", BCP 115, RFC 4395, February 2006.Melnikov & Newman Standards Track [Page 23]RFC 5092 IMAP URL Scheme November 2007Appendix A. Sample Code Here is sample C source code to convert between URL paths and IMAP mailbox names, taking into account mapping between IMAP's modified UTF-7 [IMAP4] and hex-encoded UTF-8, which is more appropriate for URLs. This code has not been rigorously tested nor does it necessarily behave reasonably with invalid input, but it should serve as a useful example. This code just converts the mailbox portion of the URL and does not deal with parameters, query, or server components of the URL./* Copyright (C) The IETF Trust (2007). This version of sample C code is part of RFC XXXX; see the RFC itself for full legal notices. Regarding this sample C code (or any portion of it), the authors make no guarantees and are not responsible for any damage resulting from its use. The authors grant irrevocable permission to anyone to use, modify, and distribute it in any way that does not diminish the rights of anyone else to use, modify, and distribute it, provided that redistributed derivative works do not contain misleading author or version information. Derivative works need not be licensed under similar terms. */#include <stdio.h>#include <string.h>/* hexadecimal lookup table */static const char hex[] = "0123456789ABCDEF";#define XX 127/* * Table for decoding hexadecimal in %encoding */static const char index_hex[256] = { XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,XX,XX, XX,XX,XX,XX, XX,10,11,12, 13,14,15,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,10,11,12, 13,14,15,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX,Melnikov & Newman Standards Track [Page 24]RFC 5092 IMAP URL Scheme November 2007 XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX,};#define HEXCHAR(c) (index_hex[(unsigned char)(c)])/* "gen-delims" excluding "/" but including "%" */#define GENERAL_DELIMS_NO_SLASH ":?#[]@" "%"/* "gen-delims" (excluding "/", but including "%") plus subset of "sub-delims" */#define GENERAL_UNSAFE_NO_SLASH GENERAL_DELIMS_NO_SLASH ";&=+"#define OTHER_UNSAFE " \"<>\\^`{|}"/* URL unsafe printable characters */static const char mailbox_url_unsafe[] = GENERAL_UNSAFE_NO_SLASH OTHER_UNSAFE;/* UTF7 modified base64 alphabet */static const char base64chars[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+,";#define UNDEFINED 64/* UTF16 definitions */#define UTF16MASK 0x03FFUL#define UTF16SHIFT 10#define UTF16BASE 0x10000UL#define UTF16HIGHSTART 0xD800UL#define UTF16HIGHEND 0xDBFFUL#define UTF16LOSTART 0xDC00UL#define UTF16LOEND 0xDFFFUL/* Convert an IMAP mailbox to a URL path * dst needs to have roughly 4 times the storage space of src * Hex encoding can triple the size of the input * UTF-7 can be slightly denser than UTF-8 * (worst case: 8 octets UTF-7 becomes 9 octets UTF-8) */void MailboxToURL(char *dst, char *src){ unsigned char c, i, bitcount; unsigned long ucs4, utf16, bitbuf; unsigned char base64[256], utf8[6]; /* initialize modified base64 decoding table */Melnikov & Newman Standards Track [Page 25]RFC 5092 IMAP URL Scheme November 2007 memset(base64, UNDEFINED, sizeof (base64)); for (i = 0; i < sizeof (base64chars); ++i) { base64[(int) base64chars[i]] = i; } /* loop until end of string */ while (*src != '\0') { c = *src++; /* deal with literal characters and &- */ if (c != '&' || *src == '-') { /* NB: There are no "URL safe" characters after the '~' */ if (c < ' ' || c > '~' || strchr(mailbox_url_unsafe, c) != NULL) { /* hex encode if necessary */ dst[0] = '%'; dst[1] = hex[c >> 4]; dst[2] = hex[c & 0x0f]; dst += 3; } else { /* encode literally */ *dst++ = c; } /* skip over the '-' if this is an &- sequence */ if (c == '&') ++src; } else { /* convert modified UTF-7 -> UTF-16 -> UCS-4 -> UTF-8 -> HEX */ bitbuf = 0; bitcount = 0; ucs4 = 0; while ((c = base64[(unsigned char) *src]) != UNDEFINED) { ++src; bitbuf = (bitbuf << 6) | c; bitcount += 6;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -