Author Topic: Garbled Characters in File Names when Using the enigma Plugin  (Read 6816 times)

Offline dgkato

  • Newbie
  • *
  • Posts: 1
I hope this message finds you well. First and foremost, I would like to inform you that English is not my native language, so please excuse any language issues in this report.

I have encountered a bug related to the enigma plugin in Roundcube. When using the plugin to encrypt attachments, the file names become garbled. Only the initial few characters of the file names are displayed correctly. However, when the enigma plugin is not used, the file names are displayed correctly.

- OS: Ubuntu 20.04 LTS
- PHP: 7.4.3
- Roundcube: 1.6.2

It seems that during the execution condition of `rawurldecode` in `rcube_mime_decode.php`, only `filename*0*` matches the Content-Disposition header. However, during decryption, the character encoding does not persist, resulting in failed decoding for the second line and onwards.

Here is the relevant code snippet from `./program/lib/Roundcube/rcube_mime_decode.php`:

Code: [Select]
protected function parseHeaderValue($input)
    if (preg_match("/^(([^']*)'[^']*')/", $val, $m)) {
       $val = rawurldecode(substr($val, strlen($m[0])));

Currently, the file names are displayed as follows:

Original file name: 012345_あいうえおかきくけこさしすせそ.txt
File name when using the enigma plugin: 012345_あいうえお%E3%81%8B%E3%81%8D%E3%81%8F%E3%81%91%E3%81%93%E3%81%95%E3%81%97%E3%81%99%E3%81%9B%E3%81%9D.txt

Code: [Select]
Content-Disposition: attachment;
 filename*0*=UTF-8''012345_%E3%81%82%E3%81%84%E3%81%86%E3%81%88%E3%81%8A; filename*1*=%E3%81%8B%E3%81%8D%E3%81%8F%E3%81%91%E3%81%93%E3%81%95%E3%81;

I kindly request your assistance in resolving this issue. Could you please make the necessary modifications to ensure that the character encoding is preserved during decryption for all lines, starting from the second line?

Thank you for your attention to this matter. I appreciate your support and effort in addressing this bug.