apps/email/js/ext/mailapi/composite/configurator.js
/**
 * Decode the modified utf-7 representation used to encode mailbox names to
 * lovely unicode.
 *
 * Notes:
 * - '&' enters mutf-7 mode, '-' exits it (and exiting is required!), but '&-'
 *    encodes a '&' rather than * a zero-length string.
 * - ',' is used instead of '/' for the base64 encoding
 *
 * Learn all about it at:
 * https://tools.ietf.org/html/rfc3501#section-5.1.3
 */
Decode the modified utf-7 representation used to encode mailbox names to
lovely unicode.




Decode the modified utf - 7 representation used to encode mailbox names to lovely unicode .
function decodeModifiedUtf7(encoded) {
  return encoded.replace(
    RE_MUTF7,
    function replacer(fullMatch, b64data) {
      if (!b64data.length)
        return '&';
      b64data = b64data.replace(RE_COMMA, '/');
      var u16data = new Buffer(b64data, 'base64');
      return u16data.toString('utf-16be');
    });
}
function decodeModifiedUtf7 ( encoded ) { return encoded . replace ( RE_MUTF7 , function replacer ( fullMatch , b64data ) { if ( ! b64data . length ) return '&' ; b64data = b64data . replace ( RE_COMMA , '/' ) ; var u16data = new Buffer ( b64data , 'base64' ) ; return u16data . toString ( 'utf-16be' ) ; } ) ; }
Decode the modified utf-7 representation used to encode mailbox names to
 lovely unicode.
Decode the modified utf - 7 representation used to encode mailbox names to lovely unicode .
// &- encodes & // we use a funky base64 where ',' is used instead of '/'... // The base-64 encoded utf-16 gets converted into a buffer holding the // utf-16 encoded bits. // and this actually decodes the utf-16 into a JS string.