PDF attachments change to unusable DAT files

I have a system that is an internal solution trying to send invoices to customers. This system works just fine, except that one client receives .dat files instead of the well-generated .pdf files that everyone else receives.

I investigated the problem, and many things point to problems with Outlook sending emails (without using outlook) and sharing files, because they are large (this is not so, we can manually send mail by email.)

Files are renamed to something like "= _utf-8_B_Q29uc29saWRhdGVkIEludm9pY2VzIGZv.dat" instead of "1180426.pdf".

After the headers in both files are just strings of characters that mean nothing to me.

.dat file headers: file1

=?utf-8?B?Y2lCQmJIQm9ZU0JKYm5OMWJHRjBhVzl1Pz0NCiA9P3V0Zi04P0I/SUNZ?=\ \ =?utf-8?B?Z1YyRjBaWEp3Y205dlptbHVaeUF0SUVGc2NHaGhJRWx1YzNWc1lYUnBi?=\ \ =?utf-8?B?MjRnSmlCWFlYUmw/PQ0KID0/dXRmLTg/Qj9jbkJ5YjI5bWFXNW5JT0tB?=\ \ =?utf-8?B?a3lCVmJtbDJaWEp6WVd3Z1EybDBlU3dnS0RJd01USXRNRFF0TVRNcD89?=\ \ =?utf-8?B?DQogPT91dGYtOD9CP0xuQmtaZz09Pz0=?=" Content-Transfer-Encoding: base64 Content-Disposition: attachment 

file2

  =?utf-8?B?YUdFZ1NXNXpkV3hoZEdsdmJpQW1JRmRoPz0NCiA9P3V0Zi04P0I/ZEdW?=\ \ =?utf-8?B?eWNISnZiMlpwYm1jZ0xTQkJiSEJvWVNCSmJuTjFiR0YwYVc5dUlDWWdW?=\ \ =?utf-8?B?MkYwWlhKd2NtOXY/PQ0KID0/dXRmLTg/Qj9abWx1WnlEaWdKTWdWVzVw?=\ \ =?utf-8?B?ZG1WeWMyRnNJRU5wZEhrc0lDZ3lNREV5TFRBMExURXpLUzV3WkdZPT89?=\ \ =?utf-8?B??=" Content-Transfer-Encoding: base64 Content-Disposition: attachment 

Does anyone know why this is happening?

+6
source share
3 answers

From the comments:

There, a strange Unicode character is printed instead of a hyphen here in the file name: "... Waterproofing - Universal City, ...". Perhaps someone on the mail server is sensitive to non-ASCII characters, and as a result encodes it to base64. Change it to a regular ASCII hyphen, and everything should be fine.


How I found it:

First, here is the base64 online decoder that I used: http://www.opinionatedgeek.com/dotnet/tools/base64decode/

Secondly, I started by concatenating all base64 strings from the header. It is divided into several segments: for the first heading, there are 5 segments. Segments are long parts between question marks. Combining them all together, you get:

 Y2lCQmJIQm9ZU0JKYm5OMWJHRjBhVzl1Pz0NCiA9P3V0Zi04P0I/SUNZ Z1YyRjBaWEp3Y205dlptbHVaeUF0SUVGc2NHaGhJRWx1YzNWc1lYUnBi MjRnSmlCWFlYUmw/PQ0KID0/dXRmLTg/Qj9jbkJ5YjI5bWFXNW5JT0tB a3lCVmJtbDJaWEp6WVd3Z1EybDBlU3dnS0RJd01USXRNRFF0TVRNcD89 DQogPT91dGYtOD9CP0xuQmtaZz09Pz0= 

Entering this into the decoder gives:

 ciBBbHBoYSBJbnN1bGF0aW9u?= =?utf-8?B?ICYgV2F0ZXJwcm9vZmluZyAtIEFscGhhIEluc3VsYXRpb24gJiBXYXRl?= =?utf-8?B?cnByb29maW5nIOKAkyBVbml2ZXJzYWwgQ2l0eSwgKDIwMTItMDQtMTMp?= =?utf-8?B?LnBkZg==?= 

Another set of base segments. The first segment appears to be cut off, so I assume that what is included in the file name is actually part of it. So I will add this and get:

 Q29uc29saWRhdGVkIEludm9pY2VzIGZvciBBbHBoYSBJbnN1bGF0aW9u ICYgV2F0ZXJwcm9vZmluZyAtIEFscGhhIEluc3VsYXRpb24gJiBXYXRl cnByb29maW5nIOKAkyBVbml2ZXJzYWwgQ2l0eSwgKDIwMTItMDQtMTMp LnBkZg== 

Paste this into the decoder to make it spit out the .bin file due to a non-ASCII character. The bin file contains the full name of the PDF file.

Opening the bin file in a hex editor:

 43 6F 6E 73 6F 6C 69 64 61 74 65 64 20 49 6E 76 Consolidated Inv 6F 69 63 65 73 20 66 6F 72 20 41 6C 70 68 61 20 oices for **** 49 6E 73 75 6C 61 74 69 6F 6E 20 26 20 57 61 74 ********** & *** 65 72 70 72 6F 6F 66 69 6E 67 20 2D 20 41 6C 70 ********** - *** 68 61 20 49 6E 73 75 6C 61 74 69 6F 6E 20 26 20 ** ********** & 57 61 74 65 72 70 72 6F 6F 66 69 6E 67 20 E2 80 ************* รขโ‚ฌ 93 20 55 6E 69 76 65 72 73 61 6C 20 43 69 74 79 " ********* **** 2C 20 28 32 30 31 32 2D 30 34 2D 31 33 29 2E 70 , (2012-04-13).p 64 66 df 

Em dash sticks out like a sore thumb.

+5
source

I think that @Jeff E understood correctly: there is a non-ASCII character in the file name, and this causes problems at one end or the other. When you send a file by e-mail manually, I assume that em-dash is replaced by your regular def or another character (for example, _) by your mail client. If you change the dash in "Waterproofing - Universal City" to "-", I think it should work.

(If so, the rep should go to Jeff as he noticed unicode.)

+2
source

Is the MIME type set when your system attaches PDF files to email messages? If so, what do you use? This is a shot in the dark, but it is possible that your system is using the / pdf application incorrectly, and some combination of mail servers and involved clients gets confused and reacts, changing it to .dat.

0
source

Source: https://habr.com/ru/post/913439/


All Articles