File names with accents of attached files in emails for ticket creation got created with nontranslated filenames which render them not accessable.

The attached patch translates the parameters and dparameters of the imap structure returned by the imap_bodystruct function from MIME encoded text to UTF-8.

Tested with accented and non-accented filenames.

It might help with #707908: Attachments from mac mail being saved as noname but I couldn't test.

Comments

rsevero’s picture

Status: Active » Needs review
jeremy’s picture

Out of curiosity, is this code found in other mail handling Drupal modules too? I'd expect other modules to have this same issue, and would be interested in seeing how they solved it.

rsevero’s picture

I don't know. Just found this problem today and coded this solution right away.

Sorry for not being of much help here.

rsevero’s picture

Improving the previous patch to prevent errors if some of the properties created by imap_bodystruct are not an array and also ignoring any values that are not strings.

Returning to your question at #2 Jeremy, I don't even know any other Drupal module that deals with incoming emails. I know about a lot of them that deal with outcoming mails though. This is the main reason I don't even know where to look for what others modules might be doing in cases like this.

jeremy’s picture

Status: Needs review » Needs work

In your patch, you're updating $object but that doesn't get passed anywhere. I'd expect you'd need to update $details for this to impact anything. What am I missing? Also, can you attach an example file I can use to easily test this with?

rsevero’s picture

StatusFileSize
new16 bytes

Remember that the way PHP passes objects as parameters behaves like passing by reference for most practical matters. Please take a look at http://php.net/manual/en/language.oop5.references.php for detailed info. So the changes done to $details (and $object as it's part of $details) inside _support_get_attachments are propagated to any further access to $details.

I'm attaching a file with a accent in it's name.

rsevero’s picture

Status: Needs work » Needs review

Forgot to change status.

rsevero’s picture

Version: 6.x-1.x-dev » 6.x-1.4

Updating to latest release version.

jeremy’s picture

Status: Needs review » Needs work

Applying this patch didn't work - however, filenames are accessible with or without this patch:
http://drupalcode.org/project/support.git/commit/32ed8f4

I should have testing /before/ committing. In any case, I reverted the patch:
http://drupalcode.org/project/support.git/commit/2daf715

Another option is to enable the transliteration module, which is now supported:
#810012: Email attachments encoding and filepath problem

Wergles’s picture

Version: 6.x-1.4 » 6.x-1.8
Assigned: Unassigned » Wergles
Category: bug » feature
Status: Needs work » Needs review
StatusFileSize
new1.07 KB

I've regenerated the patch against 6.x-1.8 so it gets applied with no fuzz and no offset.

Cheers.

  • Jeremy committed 32ed8f4 on 8.x-1.x authored by rsevero
    bug #981622 by rsevero: Properly utf-8 encode attachment names
    
    
  • Jeremy committed 2daf715 on 8.x-1.x
    Revert "bug #981622 by rsevero: Properly utf-8 encode attachment names...

  • Jeremy committed 32ed8f4 on 8.x-1.x authored by rsevero
    bug #981622 by rsevero: Properly utf-8 encode attachment names
    
    
  • Jeremy committed 2daf715 on 8.x-1.x
    Revert "bug #981622 by rsevero: Properly utf-8 encode attachment names...
purencool’s picture

Issue summary: View changes
Status: Needs review » Closed (outdated)