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

Header parsing issue #495

Open
prdatur opened this issue May 26, 2024 · 0 comments
Open

Header parsing issue #495

prdatur opened this issue May 26, 2024 · 0 comments

Comments

@prdatur
Copy link

prdatur commented May 26, 2024

Describe the bug
If a header like the received-header is per definition a multi value (header key exists multiple times), the parsed headers are broken.

Used config
default config.

Code to Reproduce
The troubling code section which produces the reported bug.

        new ClientManager();
        $header = new Header('
Received: from RECEIVED-BY-SERVER-1.localhost (RECEIVED-BY-SERVER-1.localhost [127.0.0.1])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256)
	(No client certificate requested)
	by OUR-MAIL-SERVER.localhost (Postfix) with ESMTPS id BDB91E00EE
	for <TO-EMAIL@localhost>; Tue, 26 Mar 2024 10:29:52 +0100 (CET)
Received: by RECEIVED-BY-SERVER-1.localhost with SMTP id 111111-111111.1
        for <TO-EMAIL@localhost>; Tue, 26 Mar 2024 02:29:52 -0700 (PDT)
');
       print_r($header);

Current behaviour

[attributes:protected] => Array
        (
            [received] => Webklex\PHPIMAP\Attribute Object
                (
                    [name:protected] => received
                    [values:protected] => Array
                        (
                            [0] => from RECEIVED-BY-SERVER-1.localhost (RECEIVED-BY-SERVER-1.localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)  key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by OUR-MAIL-SERVER.localhost (Postfix) with ESMTPS id BDB91E00EE for <TO-EMAIL@localhost>; Tue, 26 Mar 2024 10:29:52 +0100 (CET) by RECEIVED-BY-SERVER-1.localhost with SMTP id 111111-111111.1        for <TO-EMAIL@localhost>; Tue, 26 Mar 2024 02:29:52 -0700 (PDT)
                            [1] => from RECEIVED-BY-SERVER-1.localhost (RECEIVED-BY-SERVER-1.localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)  key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by OUR-MAIL-SERVER.localhost (Postfix) with ESMTPS id BDB91E00EE for <TO-EMAIL@localhost>
                        )

                )

            [priority] => Webklex\PHPIMAP\Attribute Object
                (
                    [name:protected] => priority
                    [values:protected] => Array
                        (
                            [0] => 0
                        )

                )

        )

Expected behavior

[attributes:protected] => Array
        (
            [received] => Webklex\PHPIMAP\Attribute Object
                (
                    [name:protected] => received
                    [values:protected] => Array
                        (
                            [0] => from RECEIVED-BY-SERVER-1.localhost (RECEIVED-BY-SERVER-1.localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)  key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by OUR-MAIL-SERVER.localhost (Postfix) with ESMTPS id BDB91E00EE for <TO-EMAIL@localhost>; Tue, 26 Mar 2024 10:29:52 +0100 (CET)
                            [1] => by RECEIVED-BY-SERVER-1.localhost with SMTP id 111111-111111.1        for <TO-EMAIL@localhost>; Tue, 26 Mar 2024 02:29:52 -0700 (PDT)
                        )

                )

            [priority] => Webklex\PHPIMAP\Attribute Object
                (
                    [name:protected] => priority
                    [values:protected] => Array
                        (
                            [0] => 0
                        )

                )

        )

Screenshots

Desktop / Server (please complete the following information):

  • OS: Ubuntu 20.04
  • PHP: 8.0.14
  • Version v5.5.0
  • Provider Dovecot

Additional context

Also the extractHeaderExtensions will modify the received headers, as i noticed, so also with a "hacky" fix, to just return $values for received key arround line 298 in Header.php, it will use it as an extension and add the first received header value without the timestamp to be end of the received header array.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant