-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Support commas in names #6267
Support commas in names #6267
Conversation
@davidwindell your branch needs to be rebased |
@davidwindell are you based on current master? Check if your master is in sync with upstream |
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); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 (")
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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!
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. |
The problem seems to be larger than expected. |
Clearing milestone, re-assigning to @DASPRiD |
@DASPRiD @davidwindell could you add a brief-ish synopsis of what's left to do on this? |
I'm assigning to 2.4. While we likely need a more robust solution, we simply need any solution at this time. |
@davidwindell I just attempted to merge this, but have a new failing test:
Could you please investigate? |
@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. |
@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. |
I agree, I have updated the test so this should be ready to merge. |
Merged to develop for release with 2.4. |
…/hotfix-address-commas Support commas in names
Bad things happen when an email header has a comma in the name, this fixes that.