Ticket #196: decode_imap_folder.diff

File decode_imap_folder.diff, 3.2 KB (added by naoki iimura, 9 years ago)

A patch to decode IMAP folder names

  • skins/default/imap-bucket-folders.thtml

     
    1818
    1919    <TMPL_LOOP NAME="IMAP_loop_mailboxes">
    2020
    21         <option value="<TMPL_VAR NAME="IMAP_mailbox">" <TMPL_VAR NAME="IMAP_selected">>
    22             <TMPL_VAR NAME="IMAP_mailbox">
     21        <option value="<TMPL_VAR NAME="IMAP_mailbox" ESCAPE=HTML>" <TMPL_VAR NAME="IMAP_selected">>
     22            <TMPL_VAR NAME="IMAP_mailbox_decoded" ESCAPE=HTML>
    2323        </option>
    2424
    2525    </TMPL_LOOP>
  • skins/default/imap-watch-folders.thtml

     
    1414
    1515    <TMPL_LOOP NAME="IMAP_loop_mailboxes">
    1616
    17         <option value="<TMPL_VAR NAME="IMAP_mailbox">" <TMPL_VAR NAME="IMAP_selected">>
     17        <option value="<TMPL_VAR NAME="IMAP_mailbox" ESCAPE=HTML>" <TMPL_VAR NAME="IMAP_selected">>
    1818
    19         <TMPL_VAR NAME="IMAP_mailbox">
     19        <TMPL_VAR NAME="IMAP_mailbox_decoded" ESCAPE=HTML>
    2020
    2121        </option>
    2222
  • Services/IMAP.pm

     
    11881188
    11891189                    $data_mailboxes{IMAP_mailbox} = $mailbox;
    11901190
     1191                    my $decoded_mailbox = $self->decode_imap_folder_name__( $mailbox, $language );
     1192                    $data_mailboxes{IMAP_mailbox_decoded} = $decoded_mailbox;
     1193
    11911194                    # Is it currently selected?
    11921195                    if ( $folder eq $mailbox ) {
    11931196                        $data_mailboxes{IMAP_selected} = 'selected="selected"';
     
    12461249
    12471250                    $inner_data{IMAP_mailbox} = $mailbox;
    12481251
     1252                    my $decoded_mailbox = $self->decode_imap_folder_name__( $mailbox, $language );
     1253                    $inner_data{IMAP_mailbox_decoded} = $decoded_mailbox;
     1254
    12491255                    if ( defined $output && $output eq $mailbox ) {
    12501256                        $inner_data{IMAP_selected} = 'selected="selected"';
    12511257                    }
     
    12891295
    12901296# ----------------------------------------------------------------------------
    12911297#
     1298# decode_imap_folder_name__
     1299#
     1300#    $name            A folder name to decode
     1301#    $language        The language currently in use
     1302#
     1303# ----------------------------------------------------------------------------
     1304
     1305sub decode_imap_folder_name__ {
     1306    my $self     = shift;
     1307    my $name     = shift;
     1308    my $language = shift;
     1309
     1310    # IMAP server encodes non-ascii folder name in IMAP-UTF-7.
     1311    my $decoded_name = $name;
     1312    if ( $$language{LanguageCode} eq 'ja' ) {
     1313        require Encode;
     1314        require Encode::IMAPUTF7;
     1315
     1316        Encode::from_to( $decoded_name, 'IMAP-UTF-7', $$language{LanguageCharset} );
     1317    }
     1318
     1319    return $decoded_name;
     1320}
     1321
     1322
     1323# ----------------------------------------------------------------------------
     1324#
    12921325# validate_item
    12931326#
    12941327#    $name            The name of the item being configured, was passed in by the call