pike.git / lib / modules / MIME.pmod / module.pmod

version» Context lines:

pike.git/lib/modules/MIME.pmod/module.pmod:1:   // -*- Pike -*-   //   // RFC1521 functionality for Pike   //   // Marcus Comstedt 1996-1999       - //! RFC1521, the @b{Multipurpose Internet Mail Extensions@} memo, defines a + //! @rfc{1521@}, the @b{Multipurpose Internet Mail Extensions@} memo, defines a   //! structure which is the base for all messages read and written by   //! modern mail and news programs. It is also partly the base for the - //! HTTP protocol. Just like RFC822, MIME declares that a message should + //! HTTP protocol. Just like @rfc{822@}, MIME declares that a message should   //! consist of two entities, the headers and the body. In addition, the   //! following properties are given to these two entities:   //!   //! @dl   //! @item Headers   //! @ul   //! @item   //! A MIME-Version header must be present to signal MIME compatibility   //! @item   //! A Content-Type header should be present to describe the nature of
pike.git/lib/modules/MIME.pmod/module.pmod:263:    case "7bit":    case "8bit":    case "binary":    return data;    default:    error("Unknown transfer encoding %s.\n", encoding);    }   }      //! Extracts the textual content and character set from an @i{encoded word@} - //! as specified by RFC1522. The result is an array where the first element + //! as specified by @rfc{1522@}. The result is an array where the first element   //! is the raw text, and the second element the name of the character set.   //! If the input string is not an encoded word, the result is still an array,   //! but the char set element will be set to 0.   //!   //! @note   //! Note that this function can only be applied to individual encoded words.   //!   //! @seealso   //! @[MIME.encode_word()]   //!
pike.git/lib/modules/MIME.pmod/module.pmod:296:    break;    default:    error( "Invalid rfc1522 encoding %s.\n", encoding );    }    return ({ decode( replace( encoded_text, "_", " " ), encoding ),    lower_case( charset ) });    } else    return ({ word, 0 });   }    - //! Create an @i{encoded word@} as specified in RFC1522 from an array + //! Create an @i{encoded word@} as specified in @rfc{1522@} from an array   //! containing a raw text string and a char set name.   //!   //! The text will be transfer encoded according to the encoding argument,   //! which can be either @expr{"base64"@} or @expr{"quoted-printable"@}   //! (or either @expr{"b"@} or @expr{"q"@} for short).   //!   //! If either the second element of the array (the char set name), or   //! the encoding argument is 0, the raw text is returned as is.   //!   //! @seealso
pike.git/lib/modules/MIME.pmod/module.pmod:397:    } else {    res += ({ word });    }    }    return res;   }      //! Like @[MIME.decode_words_text()], but the extracted strings are   //! also remapped from their specified character encoding into UNICODE,   //! and then pasted together. The result is thus a string in the original - //! text format, without RFC1522 escapes, and with all characters in UNICODE + //! text format, without @rfc{1522@} escapes, and with all characters in UNICODE   //! encoding.   //!   //! @seealso   //! @[MIME.decode_words_tokenized_remapped]   //!   string decode_words_text_remapped( string txt )   {    return Array.map(decode_words_text(txt), remap)*"";   }   
pike.git/lib/modules/MIME.pmod/module.pmod:430:   {    return Array.map(tokenize(phrase, flags),    lambda(string|int item) {    return intp(item)? item : decode_word(item);    });   }      //! Like @[MIME.decode_words_tokenized()], but the extracted atoms are   //! also remapped from their specified character encoding into UNICODE.   //! The result is thus identical to that of @[MIME.tokenize()], but - //! without RFC1522 escapes, and with all characters in UNICODE encoding. + //! without @rfc{1522@} escapes, and with all characters in UNICODE encoding.   //!   //! @seealso   //! @[MIME.decode_words_tokenized_labled_remapped]   //! @[MIME.decode_words_text_remapped]   //!   array(string|int) decode_words_tokenized_remapped( string phrase,    int|void flags )   {    return Array.map(decode_words_tokenized(phrase, flags),    lambda(array(string)|int item) {
pike.git/lib/modules/MIME.pmod/module.pmod:489:    return ({ "comment", decode_words_text(item[1]) });    default:    return item;    }    });   }      //! Like @[MIME.decode_words_tokenized_labled()], but the extracted words are   //! also remapped from their specified character encoding into UNICODE.   //! The result is identical to that of @[MIME.tokenize_labled()], but - //! without RFC1522 escapes, and with all characters in UNICODE encoding. + //! without @rfc{1522@} escapes, and with all characters in UNICODE encoding.   //!   array(array(string|int))   decode_words_tokenized_labled_remapped(string phrase, int|void flags)   {    return Array.map(decode_words_tokenized_labled(phrase, flags),    lambda(array(string|int|array(array(string|int))) item) {    switch(item[0]) {    case "word":    return ({ "word", remap(item[1..]) });    case "comment":
pike.git/lib/modules/MIME.pmod/module.pmod:708:    replacement,    repcb) });    default:    return item;    }    }));   }      //! Provide a reasonable default for the subtype field.   //! - //! Some pre-RFC1521 mailers provide only a type and no subtype in the + //! Some pre-@rfc{1521@} mailers provide only a type and no subtype in the   //! Content-Type header field. This function can be used to obtain a   //! reasonable default subtype given the type of a message. (This is done   //! automatically by the @[MIME.Message] class.)   //!   //! Currently, the function uses the following guesses:   //! @string   //! @value "text"   //! @expr{"plain"@}   //! @value "message"   //! @expr{"rfc822"@}
pike.git/lib/modules/MIME.pmod/module.pmod:1609:    }    foreach(indices(enclosing_headers), string h) {    if(h != "message-id" && h != "encrypted" && h != "mime-version" &&    h != "subject" && (sizeof(h)<8 || h[0..7] != "content-"))    reconstructed->headers[h] = enclosing_headers[h];    }    return reconstructed;    } else return (maxgot>total? -1 : total-got);   }    - //! Encode strings according to RFC 4648 base64url encoding. + //! Encode strings according to @rfc{4648@} base64url encoding.   string encode_base64url(string x)   {    x = replace(encode_base64(x,1),({ "+", "/" }),({ "-", "_" }));    while( sizeof(x) && x[-1]=='=' ) x=x[..<1];    return x;   }    - //! Decode strings according to RFC 4648 base64url encoding. + //! Decode strings according to @rfc{4648@} base64url encoding.   string decode_base64url(string x)   {    return decode_base64(replace(x,({ "-", "_" }),({ "+", "/" })));   }