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

Misc changes #114

Closed
wants to merge 7 commits into from
Closed

Misc changes #114

wants to merge 7 commits into from

Conversation

holdmann
Copy link

@holdmann holdmann commented Apr 3, 2016

Misc changes with encodings, exceptions handle, new exceptions and so one, look at commit messages for details.

holdmann added 7 commits April 4, 2016 01:30
Notices generates by c-client that wrapped by imap extensions, so no other way to solve that.
…ed with "UNKNOWN SEARCH CRITERION", may be there are any others, so throw general library exception.
…-Y \(H:i:s\) that throws exception, so use zero timestamp if no well-formatted date in message headers presented.
…han ENCOTHER. php imap returns encoding in between 6 and 10 if encoding is unsupported, so there is no way to decode just throws exception.
This was referenced Sep 22, 2017
@@ -75,7 +75,7 @@ public function getMailbox($name)
throw new MailboxDoesNotExistException($name);
}

return new Mailbox($this->server . imap_utf7_encode($name), $this);
return new Mailbox($this->server . mb_convert_encoding($name, "UTF7-IMAP", "UTF-8"), $this);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implemented in #193 due to the heavy refactored code.
Thank you for your help

$decoded .= $part->text;
} catch (\Ddeboer\Transcoder\Exception\IllegalCharacterException $ex) {
// force transcoding using iconv and ignore.
$decoded .= @iconv($charset, 'UTF-8//IGNORE', $part->text);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have any example for this case?

@@ -218,6 +219,11 @@ protected function parseStructure(\stdClass $structure)
$this->type = self::TYPE_UNKNOWN;
}

// fix strange encoding that more than ENCOTHER = 5
if ($structure->encoding > ENCOTHER) {
throw new MessageUnsupportedEncodeException($this->messageNumber, $this->partNumber);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implemented in #197 thank you for your feedback

// Thus wait while php core team fix that, some guys waits about 5 year, ha-ha
// @see http://php.net/manual/ru/function.imap-headerinfo.php#98809
$headers = imap_rfc822_parse_headers(
imap_fetchheader($this->stream, imap_msgno($this->stream, $this->messageNumber))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Partially implemented in #202 thank you

} else {
throw new Exception($lastError);
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Slamdunk Slamdunk added the bug label Sep 29, 2017
@Slamdunk Slamdunk added this to the 1.0 milestone Sep 29, 2017
return new \DateTime($value);
try {
$dateTime = new \DateTime($value);
} catch (\Exception $e) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you provide dates that throw exceptions?

@Slamdunk
Copy link
Collaborator

If you'll face date that get DateTime to throw exceptions please ping me or PR the case to the dedicated data set:

imap/tests/MessageTest.php

Lines 320 to 330 in 0fee1a7

public function provideDateCases(): array
{
return [
['2017-09-28T09:24:01+0000', 'Thu, 28 Sep 2017 09:24:01 +0000 (UTC)'],
['2014-06-13T17:18:44+0200', '=?ISO-8859-2?Q?Fri,_13_Jun_2014_17:18:44_+020?=' . "\r\n" . ' =?ISO-8859-2?Q?0_(St=F8edn=ED_Evropa_(letn=ED_=E8as))?='],
['2008-02-13T02:15:46+0000', '13 Feb 08 02:15:46'],
['2008-04-03T12:36:15-0700', '03 Apr 2008 12:36:15 PDT'],
['2004-08-12T23:38:38-0700', 'Thu, 12 Aug 2004 11:38:38 PM -0700 (PDT)'],
['2006-01-04T21:47:28+0000', 'WED 04, JAN 2006 21:47:28'],
];
}

And we'll try to handle it as well.

All other suggested edit were implemented in specific PR with related test. Thank you for you feedback.

@Slamdunk Slamdunk closed this Sep 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants