Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

Support commas in names #6267

Closed

Conversation

davidwindell
Copy link
Contributor

Bad things happen when an email header has a comma in the name, this fixes that.

@Ocramius
Copy link
Member

@davidwindell your branch needs to be rebased

@Ocramius Ocramius modified the milestones: 2.4.0, 2.3.2 May 13, 2014
@Ocramius
Copy link
Member

@davidwindell are you based on current master? Check if your master is in sync with upstream

@DASPRiD
Copy link
Member

DASPRiD commented May 14, 2014

Please add new tests instead of modifying existing ones.

@@ -57,7 +57,7 @@ public function testGetDecodedHeader()
{
$message = new Message(array('file' => $this->_file));

$this->assertEquals('"Peter Müller" <peter-mueller@example.com>', $message->from);
Copy link
Member

Choose a reason for hiding this comment

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

Why was this test modified?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because I'm using str_getcsv it's removing the enclosure characters ", I'm not sure if this matters or if there is a clean way around it.

Copy link
Member

Choose a reason for hiding this comment

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

This actively modifies the behaviour, thus it'd be a BC break. Existing tests should not be altered. Exception is if the test would be wrong of course.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I'll leave it to someone else to implement as not sure how else to do but with str_getcsv

Although, one could say the test was wrong on the basis that the enclosure is part of the "encoding" and this is getting the "decoded" version.

Copy link
Member

Choose a reason for hiding this comment

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

Looking at the test, it does exactly what it should.

Copy link
Member

Choose a reason for hiding this comment

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

I'm not too much into perl, but as far as I can see, $string_ref is a reference to the string there, and what the loop actually does is: Parse address from the string, then advance to the next comma, then repeat.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think that is going to help us then :(, what we need is a simple regex that will split a string on commas, but not where they are enclosed by speech marks (")

Copy link
Member

Choose a reason for hiding this comment

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

That's not that easy, because quotation marks can be escaped.

Copy link
Member

Choose a reason for hiding this comment

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

Anyway, I'm gonna take a look at a possible regex solution later today.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's why I had hoped str_getcsv would work ;) :(

Thank you sir!

@davidwindell
Copy link
Contributor Author

As per previous discussion, tests have been reverted. There is a problem however in that speech marks are stripped out by str_getcsv. @DASPRiD is looking into a regex solution for this instead.

@DASPRiD
Copy link
Member

DASPRiD commented Jul 22, 2014

The problem seems to be larger than expected. Zend\Mail does not handle quoted names at all right now, so this will take a more complex solution.

@Ocramius Ocramius removed this from the 2.3.2 milestone Jul 27, 2014
@Ocramius Ocramius assigned DASPRiD and unassigned Ocramius Jul 27, 2014
@Ocramius
Copy link
Member

Clearing milestone, re-assigning to @DASPRiD

@ezimuel ezimuel added this to the 2.4.0 milestone Aug 6, 2014
@Ocramius Ocramius removed this from the 2.4.0 milestone Nov 14, 2014
@adamlundrigan
Copy link
Contributor

@DASPRiD @davidwindell could you add a brief-ish synopsis of what's left to do on this?

@weierophinney
Copy link
Member

I'm assigning to 2.4. While we likely need a more robust solution, we simply need any solution at this time.

@weierophinney
Copy link
Member

@davidwindell I just attempted to merge this, but have a new failing test: ZendTest\Mail\Storage\MessageTest::testGetDecodedHeader now fails, asserting that:

Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'"Peter Müller" <peter-mueller@example.com>'
+'Peter Müller <peter-mueller@example.com>'

Could you please investigate?

@davidwindell
Copy link
Contributor Author

@weierophinney Are you happy for test to be modified to remove the speech marks around the name? That's what str_getcsv will do and was what prompted Dasprid's concerns with the PR.

@weierophinney
Copy link
Member

@davidwindell I think that would be fine; they're an optional part of the standard, and do not affect usability within messages in any meaningful way.

@davidwindell
Copy link
Contributor Author

I agree, I have updated the test so this should be ready to merge.

weierophinney added a commit that referenced this pull request Feb 24, 2015
weierophinney added a commit that referenced this pull request Feb 24, 2015
@weierophinney
Copy link
Member

Merged to develop for release with 2.4.

weierophinney added a commit to zendframework/zend-mail that referenced this pull request May 14, 2015
…/hotfix-address-commas

Support commas in names
weierophinney added a commit to zendframework/zend-mail that referenced this pull request May 14, 2015
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants