zendframework / zend-mail

Mail component from Zend Framework
BSD 3-Clause "New" or "Revised" License
96 stars 111 forks source link

ListParser::parse parses string incorrectly #222

Open svaningelgem opened 5 years ago

svaningelgem commented 5 years ago

Code to reproduce the issue

include "vendor\zendframework\zend-mail\src\Header\ListParser.php"
var_dump(\Zend\Mail\Header\ListParser::parse("\"a'b\" <abc@host.be>, def <def@host.be>"));

Expected results

array(2) { [0]=> string(19) ""a'b" abc@host.be" [1]=> string(18) " def def@host.be" }

Actual results

array(1) { [0]=> string(38) ""a'b" abc@host.be, def def@host.be" }

Solution

Add the following else-if branch under the current one. Rationale: if you're in a quoted-string, don't look for more quotes as they're part of the comment.

            if ($char === $currentQuoteDelim) {
                $inQuote = false;
                $currentQuoteDelim = null;
                continue;
            }
            // We are in a quote, but encountered another quote-char: don't do anything.
            else if ( $inQuote ) {
              continue;
            }
weierophinney commented 4 years ago

This repository has been closed and moved to laminas/laminas-mail; a new issue has been opened at https://github.com/laminas/laminas-mail/issues/21.