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

"Invalid header name detected" (From XXX) on upgrades #427

Closed
vladsf opened this issue Dec 25, 2018 · 8 comments
Closed

"Invalid header name detected" (From XXX) on upgrades #427

vladsf opened this issue Dec 25, 2018 · 8 comments
Milestone

Comments

@vladsf
Copy link
Contributor

vladsf commented Dec 25, 2018

Hi,

I have "Invalid header name detected" issue on 'php bin/upgrade' running and in browser viewing older issues e.g. http://eventumtest01.test.com/view_email.php?ema_id=20&id=236398

I saw #155 issue, but the fix does not solve the trouble on upgrades or views.

Eventum v3.1.10 - php bin/upgrade:

[2018-12-24 15:44:05] db.INFO: skipped maq_id=867359, exception: Line "From xxx.xxx@company.com  Mon Jan  5 13: 05:51 2015"does not match header f
ormat! [] {"file":"/intranet/eventum-3.1.10/upgrade/patches/56_maq_message_id.php","line":52,"class":"Eventum\\Db\\Migrate","function":"{closure}","memory_
usage":"68.5 MB","memory_peak_usage":"74 MB","version":"3.1.10","usr_id":""}

The same on upgrade run from 3.2.0 to 3.5.4:

[2018-12-25 10:14:15] db.INFO: skipped maq_id=867198, exception: Invalid header name detected [] {"file":"/intranet/eventum-3.5.4/db/migrations/20180306202659_eventum_maq_message_id.php","line":49,"class":"EventumMaqMessageId","function":"up","memory_usage":"42.75 MB","memory_peak_usage":"45.25 MB","version":"3.5.4","usr_id":""}

Then it fails in browser (shows empty page) and eventum.log gets:

[2018-12-25 10:34:25] app.ERROR: Uncaught Exception Zend\Mail\Header\Exception\InvalidArgumentException: "Invalid header name detected From name.surname@test.com  Wed Dec 19 08" at /intranet/eventum/vendor/zendframework/zend-mail/src/Header/GenericHeader.php line 57 {"exception":"[object] (Zend\\Mail\\Header\\Exception\\InvalidArgumentException(code: 0): Invalid header name detected From name.surname@test.com  Wed Dec 19 08 at /intranet/eventum/vendor/zendframework/zend-mail/src/Header/GenericHeader.php:57)"} {"url":"/view_email.php?ema_id=20&id=236695","ip":"10.xx.xx.xx","http_method":"GET","server":"eventumtest01.test.com","referrer":"http://eventumtest01.test.com/view.php?id=62010","unique_id":"XCIHsd2LuhHFE9IJ6@2unQAAAAE","file":null,"line":null,"class":null,"function":null,"memory_usage":"11.75 MB","memory_peak_usage":"11.75 MB","version":"3.5.4","usr_id":"107"}

The emails in the database are from Eventum 2.3.6, fetched from IMAP server. I am testing upgrade from 2.3.6 to 3.5.4.

One option is to ignore src/Header/GenericHeader.php exceptions, but the impact of this hack is not clear. Also it is not obvious if I shall run bin/upgrade again.

@vladsf
Copy link
Contributor Author

vladsf commented Dec 25, 2018

installed Xdebug and got this:

Eventum\Mail\Helper\MailLoader::fixBrokenHeaders is called at /intranet/eventum/src/Mail/Helper/MailLoader.php:114Eventum\Mail\Helper\MailLoader::fixBrokenHeaders is called at /intranet/eventum/src/Mail/Helper/MailLoader.php:121

@vladsf
Copy link
Contributor Author

vladsf commented Dec 25, 2018

I suggest this fix to be applied to src/Mail/Helper/MailLoader.php:
iss427-diff.txt

@glensc
Copy link
Member

glensc commented Dec 26, 2018

  1. use code fence markdown to wrap code blocks (and logs)
  2. submit your proposal as pull request
  3. include example email to tests/data, see tests/Mail/LoadEmailTest.php for similar cases: Mail: Rename unparseable headers #406, Handle uncaught header exception from mail download #398, Handle broken Sender header from IMAP #423

@glensc glensc added this to the 3.5.5 milestone Dec 26, 2018
@glensc glensc modified the milestones: 3.5.5, 3.5.6 Dec 26, 2018
@glensc
Copy link
Member

glensc commented Dec 26, 2018

the patch that fails is from #352 and it's errors can be ignored (as the log says)

@vladsf
Copy link
Contributor Author

vladsf commented Dec 30, 2018

Hi @glensc,
Thank you for the quick reply. I will do the pull request once I am back to keyboard from holidays.

@glensc
Copy link
Member

glensc commented Dec 30, 2018

update from 2.3.6 to 3.5.4 is huge. good luck with that! :)

btw, 3.5.5 was released few days ago with #423, which may help you.

@glensc glensc modified the milestones: 3.5.6, 3.6.0 Jan 3, 2019
vladsf added a commit to vladsf/eventum that referenced this issue Jan 9, 2019
Email viewer (view_email.php) fails with an exception "Invalid header name detected"
if a stored raw email starts with a Mbox line "From name@example.com .." which is
not a correct mail header.
@vladsf
Copy link
Contributor Author

vladsf commented Jan 9, 2019

Hi @glensc,

I have created a pull request. Eventum tests/data already has a test email for the case. I hope I made the request correctly. Thanks!

@glensc
Copy link
Member

glensc commented Jan 13, 2019

fixed via #439

@glensc glensc closed this as completed Jan 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants