2.2.3.4.1.1 File Name

The attachment file name SHOULD be determined by MIME readers in the following order:

  1. If the Content-Disposition header exists on the attachment MIME entity, and a non-empty filename parameter is available on this header, the filename parameter value SHOULD be used.

  2. Otherwise, if the Content-Type header is available on the attachment MIME entity, and a non-empty name parameter is available on this header, the name parameter value SHOULD be used.

  3. Otherwise, if the Content-Transfer-Encoding header is set to "mac-binhex40", MIME readers SHOULD try to parse the MIME part body as MacBinary structure, as specified in section 2.2.3.4.2.3. Only the first 128 bytes of the MIME body (decoded with binhex, as specified in [RFC1741]) SHOULD be parsed. If parsing of MacBinary structure succeeds, file name data from this structure SHOULD be used.

  4. Otherwise, if the attachment MIME part body is encoded with uuencode (see section 2.2.3.9.1 and [IEEE1003.1]), and it contains file name data, this file name SHOULD be used.

  5. Otherwise, if the Content-Description header is available on the attachment and its value is non-empty, it SHOULD be used as the file name value for an attachment. (Even if a file name for an attachment was found in one of the previous steps, this value SHOULD be written to the PidTagDisplayName property ([MS-OXCFOLD] section 2.2.2.2.2.5) for an attachment.)

MIME readers SHOULD sanitize the resulting file name by removing characters that are not legal but MAY<144> instead replace illegal characters with an underscore "_" (U+005F). MIME readers SHOULD<145> apply the same sanitization to the display name. Invalid characters are listed in the following table.

Description

Code point

Character

Control characters

U+0000 through U+001F<146>

Double quote

U+0022

"

Forward slash

U+002F

/

Colon

U+003A

:

Left angle bracket

U+003C

<

Right angle bracket

U+003E

>

Pipe

U+007C

|

Backslash

U+005C

\

The following steps SHOULD<147> then be applied both to the attachment file name and the display name (if the display name is not available, the empty string SHOULD be used):

  1. Replace all Unicode separator characters with spaces. Unicode separator characters are specified in [UNICODE5.1] section 6.2.

  2. Separate name into base and extension parts. The extension is defined as the trailing part of a name that starts after the last appearance of a "." character (U+002E) in the name, or an empty string if name contains no such character.

  3. Remove all leading and trailing spaces and leading and trailing "." (U+002E) characters from both the base and the extension.<148>

If the extension part of the display name is not empty and does not match the extension part of file name, it SHOULD be appended to the base part of display name.

If the file name base and/or file name extension is empty, the MIME reader SHOULD<149> generate an attachment file name base and/or extension. The filename can be created using any file name generation convention that conforms to the filename guidelines specified in this section.

After that, if the base part of the display name is empty, it SHOULD<150> be replaced with the base part of the file name. Finally, the file name base, file name extension, and display name SHOULD be reassembled from the base and extension parts and saved in the appropriate properties, as specified in the following table.

Property

Value

PidTagDisplayName ([MS-OXCFOLD] section 2.2.2.2.2.5)

<display name base>.<file name extension>

PidTagAttachLongFilename ([MS-OXCMSG] section 2.2.2.11)

<file name base>.<file name extension>

PidTagAttachExtension ([MS-OXCMSG] section 2.2.2.12)

.<file name extension>

The value saved to the PidTagAttachLongFilename property SHOULD<151> be further processed to form a valid 8.3 name, and then written to the PidTagAttachFilename property, as follows:

  1. The value SHOULD be first separated into name and extension parts, using the last "." character (U+002E) as a separator. If no such character is present, or the only appearance of this character is in the beginning of the file name, the name part is considered to be empty but the extension is not empty; the separator character itself is not included into the name or extension.

  2. MIME readers SHOULD replace the following characters with an underscore (U+005F) but MAY<152> remove them: plus sign "+" (U+002B), comma "," (U+002C), equal sign "=" (U+003D), left square bracket "[" (U+005B), right square bracket "]" (U+005D), semicolon ";" (U+003B). MIME readers MAY<153> replace the question mark "?" (U+003F) and the asterisk "*" (U+002A) with the underscore "_" (U+005F).

  3. MIME readers SHOULD<154> remove the following characters: space (U+0020), period "." (U+002E), apostrophe "'" (U+0027), asterisk "*" (U+002A), question mark "?" (U+003F), as well as characters with a UTF8 code greater than 127.

  4. If the name is empty after removing such characters, MIME readers SHOULD<155> generate a non-empty value.

  5. MIME readers SHOULD trim the name part of the file name to 8 characters. MIME readers also SHOULD trim the extension part to 3 characters. Alternatively, MIME readers MAY<156> delete the extension portion of the file name if the extension is greater than three characters in length.

  6. If the name was shortened, MIME readers SHOULD<157> additionally trim the name part to 6 characters, and "~1" SHOULD be added to its end.

  7. MIME readers then recombine the file name and extension<158>, separated by a single "." (U+002E).

Show: