Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mime: expected slash after first token #140

Merged

Conversation

requaos
Copy link
Collaborator

@requaos requaos commented Dec 21, 2019

Found occurrences of a media parameter list without a mime type, this will inject a safe default mime type.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.3%) to 92.126% when pulling a137fa5 on requaos:requaos/expectedSlashAfterToken into cf488a7 on jhillyerd:develop.

@requaos requaos self-assigned this Dec 21, 2019
@requaos
Copy link
Collaborator Author

requaos commented Dec 21, 2019

Started getting emails from a particular source, that formats the inline attachment content-type like this:
charset=binary; name="image.jpg"

Resolved by just prepending a safe default mime type to it:
application/octet-stream; charset=binary; name="image.jpg"

@jhillyerd jhillyerd merged commit 3f81043 into jhillyerd:develop Dec 23, 2019
jhillyerd added a commit that referenced this pull request Feb 23, 2020
Added
- Inject a `application/octet-stream` as default content type when none is
  present (#140, thanks requaos)
- Add support for content-type params to part & encoding (#148, thanks
  pzeinlinger)
- UTF-7 support (#17)

Fixed
- Handle missing parameter values in the middle of the media parameter list
  (#139, thanks requaos)
- Fix boundaryReader to respect length instead of capacity (#145, thanks
  dcormier)
- Handle very empty mime parts (#144, thanks dcormier)
@miknaz
Copy link

miknaz commented Oct 26, 2020

Hi guys, I also get this error expected slash after first token when try to parse some emails with enmime.ReadEnvelope(strings.NewReader(mime))

Can you suggest me please how to avoid this problem ? Below is the example of mime which gives error:

Return-Path: <bounce+aca41a.9415d2-general.c1c=libero.it@libertycomc.com>
Delivered-To: general.c1c@libero.it
Received: from dcd-15 ([10.103.10.7])
	by dcbackend-15.iol.local with LMTP id wBOnApYfll9gIAUATByfJw
	for <general.c1c@libero.it>; Mon, 26 Oct 2020 02:00:06 +0100
Received: from dcp-33.iol.local ([10.103.10.7])
	by dcd-15 with LMTP id qDyMApYfll/wYgAAkA0XfQ
	; Mon, 26 Oct 2020 02:00:06 +0100
Received: from libero.it ([10.103.10.7])
	by dcp-33.iol.local with LMTP id MPfpG5Mfll+4JAEAVzGdtA
	; Mon, 26 Oct 2020 02:00:06 +0100
Received: from so254-8.mailgun.net ([198.61.254.8])
	by smtp-07.iol.local with ESMTP
	id Wqrkk7ui19msRWqrlkdWIE; Mon, 26 Oct 2020 02:00:06 +0100
X-IOL-DMARC: Dominio libertycomc.com non supporta DMARC
X-IOL-DKIM: pass con il dominio d=libertycomc.com
X-IOL-SPF: pass con l'IP 198.12.44.3;libertycomc.com
X-IOL-SEC: _SPFOK_DKIMOK_NODMARC
x-libjamoibt: 2601
Received-SPF: pass
X-CNFS-Analysis: v=2.4 cv=KPrksHJo c=1 sm=1 tr=0 ts=5f961f96 b=1
 a=9V+36KcF1VtsQasMD0NMeA==:117 a=9V+36KcF1VtsQasMD0NMeA==:17
 a=IkcTkHD0fZMA:10 a=afefHYAZSVUA:10 a=5KLPUuaC_9wA:10 a=swULO2ODAAAA:8
 a=8IFCRQWyzuk3np_0jKQA:9 a=AFaUXfkzamQ7vrcO:21 a=frz4AuCg-hUA:10
 a=QEXdDO2ut3YA:10 a=VPRn9Uh7xMAA:10 a=PCWqMptlEwVzXmuMJime:22
Authentication-Results: smtp-07.iol.local;
	dkim=pass header.d=libertycomc.com header.b=TfJm39aZ
DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=libertycomc.com; q=dns/txt;
 s=krs; t=1603674005; h=Content-Transfer-Encoding: Mime-Version:
 Content-Type: Subject: From: To: Message-Id: Sender: Date;
 bh=faAL8rCmOc2K1K3IP+7qQSPKUakoqX/vM3mtikLFN0I=; b=TfJm39aZ1YvR3TVhRaf5BOcqO6N5ED/Kch55jvSrHK95UTu6KuKpHzAamCG9yJ4ithTOrC53
 2qQhp5E+1c7Jyt7FMAYxKXhApcqBWd7wj5lmytO+ceEb+x6+BcgmWg2+knuXwexuDlYCFxKM
 fwnBUlp5eb5+Mr3YmWVOptF/r7c=
X-Mailgun-Sending-Ip: 198.12.44.3
X-Mailgun-Sid: WyJkMDIzMiIsICJnZW5lcmFsLmNvbnN0cnVjdGlvbkBsaWJlcm8uaXQiLCAiOTQxNWQyIl0=
Received: by luna.sendgrid.net with HTTP; Mon, 26 Oct 2020 01:00:04 +0000
Date: Mon, 26 Oct 2020 01:00:04 +0000
Sender: info@libertycomc.com
Message-Id: <20201033010004.1.C8D1569B39447CD0@libertycomc.com>
To: general.c1c@libero.it
From: LibertyComc <info@libertycomc.com>
Subject: =?utf-8?q?Il_tuo_contratto_di_assistenza_LibertyOnCall_Base_?=
 =?utf-8?q?=C3=A8_scaduto?=
Content-Type: text/html; charset="utf-8"
Mime-Version: 1.0
Content-Transfer-Encoding: quoted-printable
X-CMAE-Envelope: MS4xfNvTvUqy52h0PkJMOD3B7ZoQxPkRJk/JMo2kfmIlF7l6O3wP4UkVrLsi6TBS/nxvz1zrbHrMhIiA9gTN2dELm5hM39y496Dn/14V6nFuqnxTAsnInGBo
 sNc1MmqJGgJu/m9Pgn18xzac7TKMqBPiPCe96YDU4K/A0uPOppvxJ55qoey1cHx+NwBsPzZ1VXDTLf1q+eVnP3cjfhUKW5ii5fBVuHTYbCbfNz0NmEwhpZCc
 KO9wgeZjEWpMkfZ+OzlinhYnRpDDLNYt3vmNI3J9Bsk=

<!-- BEGIN: main --><!DOCTYPE html>
<html lang=3D"it">
<head>
   <meta charset=3D"UTF-8">
   <title>Il tuo contratto di assistenza LibertyOnCall Base =C3=A8 scaduto<=
/title>
   <style type=3D"text/css">
      body {
         font-family: Verdana, Arial, Helvetica, sans-serif;
         font-size: 11px
      }
   </style>
</head>
<body>
   <div style=3D"width:100%; background-color:#f7f7f4; padding-bottom:30px;=
 padding-top:10px; margin:0">
      <div style=3D"width:640px; margin-left:auto; margin-right: auto; back=
ground-color:#ffffff;box-shadow: 0 10px 20px rgba(0,0,0,0.19), 0 6px 6px rg=
ba(0,0,0,0.23);">
         <div style=3D"padding:10px; margin:5px 0 0 0; border-bottom:1px so=
lid #dddddd; font-size:11px">
            <img src=3D"http://www.libertycomc.com/assets/email/logo_lib=
ertycommerce_piccolo.png">
         </div>
         <div style=3D"color:#333333; font-weight:bold; background-color:#e=
fefef; padding:5px 10px 8px 10px; font-size:15px; font-family:Arial,Verdana=
,sans-serif">
            Il tuo contratto di assistenza LibertyOnCall Base =C3=A8 scaduto
         </div>
         <div style=3D"color:#333333; padding:10px 10px 10px 10px; font-siz=
e:15px; font-family:Arial,Verdana,sans-serif">
           =20
<table width=3D"100%" border=3D"0" cellspacing=3D"2" cellpadding=3D"5">
	<!--
	<tr>
		<td align=3D"center" bgcolor=3D"#FF3F3F">
			<span style=3D"color: cornsilk; font-weight: bold"> Il tuo contratto di =
assistenza =C3=A8 scaduto </span>
		</td>
	</tr>
	-->

	<tr>
		<td>

			Gentile <strong>General C1C</strong>, <b=
r>
			<br>
			dai nostri archivi risulta che il contratto di assistenza
			<strong>LibertyOnCall Base</strong> da te sottoscritto =C3=A8 scaduto il=
 giorno <strong>23/10/2020</strong>.<br>
			<br>

			Per poter continuare ad usufruire del servizio ti invitiamo a rinnovarlo=
 per un altro anno. <br>
			<br>
			<div align=3D"center" style=3D"margin:10px">
				<a style=3D"text-decoration:none; font-weight: bold; background-color:#=
eee; color:#004276; border-radius: 4px; padding:8px; border:1px solid #bbbb=
bb" href=3D"http://legacy.libertycomc.com/negozio/quickbuy.php?ql=3D7B65=
D7E0A97BC35F9B576510F11119EC1B8E3205D8B08993E8DC641CC36F7FD38A8E4E219480742=
C529F7D7182734594A769813DF58839940268A486990C73722FC20809D093A41EB5261F104D=
301413CC604233EEE6B61139D18A8B94461795">Clicca per rinnovare</a>
			</div>

		=09
			<br>
		</td>
	</tr>
</table>

         </div>
         <div style=3D"text-align:center; background-color:#f6f6f6; padding=
:10px; margin:5px 0 5px 0; border-top:1px solid #dddddd; font-size:10px;  f=
ont-family:Arial,Verdana,sans-serif">&copy;2020 Liberty Line srl</div>
      </div>
   </div>
<img width=3D"1px" height=3D"1px" alt=3D"" src=3D"http://email.libertycomme=
rce.it/o/eJw1zDsSgyAUBdDVhJK5j59S0EQ3wueZMKMyg6TI7mOT5pSnBG_IFiVqUFAgKHcDGE=
lymVearH9qD5qWFQ-DvSbu45vbcXDPLOsQ7-AjJ1J-0yZats5gS4gahXl2cKxFDy8-ucdd5nZeo=
3_yqO38d-1efrQHKFQ"></body>
</html><!-- END: main -->

@jhillyerd
Copy link
Owner

Hey @miknaz - go ahead an open a new bug for this, I think this error is being caused by some header line continuation code, unrelated to this change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants