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

Incorrect Handling of Extended Header Attributes in the Parser #523

Open
more7dev opened this issue Oct 11, 2024 · 0 comments
Open

Incorrect Handling of Extended Header Attributes in the Parser #523

more7dev opened this issue Oct 11, 2024 · 0 comments

Comments

@more7dev
Copy link

The parser incorrectly treats extended header attributes as main attributes.
For example, in the header attribute x-keepsent: XXXX:XXXX-XXXX:XXXX; type=4; name=$KeepSent, the name attribute is mistakenly treated as a main attribute in the method \Webklex\PHPIMAP\Header::extractHeaderExtensions.
This behavior is problematic because it causes the name attribute to be recognized as a main attribute rather than an extension attribute. Consequently, the method \Webklex\PHPIMAP\Part::isAttachment mistakenly identifies the content as an attachment.

The issue lies in the header parser’s design.
Parsed headers’ values are stored in the attributes array, the key being header name (i.e. x-keepsent) and values being an object of class Attribute.
However when parsing extensions, i.e. type=4; name=$KeepSent, this convention is broken. The attributes array is populated with keys type and name as if they were actual header attributes. The extensions should be somehow attached to the existing object, representing the header being extended.

Considering our example x-keepsent: XXXX:XXXX-XXXX:XXXX; type=4; name=$KeepSent:
Expected behavior

attributes['x-keepsent'] = Attribute { values: [“XXXX:XXXX-XXXX:XXXX, type: 4, name: $KeepSent”, “XXXX:XXXX-XXXX:XXXX”]}

Actual Results

attributes['x-keepsent'] = Attribute { values: [“XXXX:XXXX-XXXX:XXXX, type: 4, name: $KeepSent”, “XXXX:XXXX-XXXX:XXXX”]}
attributes['type'] = 4
attributes['name'] = $KeepSent
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