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

Fix incorrect parsing of headers containing equal character #7303

Merged
merged 3 commits into from
Sep 22, 2023
Merged

Conversation

Theo024
Copy link
Contributor

@Theo024 Theo024 commented Sep 21, 2023

SUMMARY

Fix mail header parsing that skip headers containing equals characters due to missing maxsplit on header key/value parsing.

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

mail module

ADDITIONAL INFORMATION

For example, the following mail module invocation trigger the bug:

- name: Send email
  mail:
    host: "{{ smtp.host }}"
    port: "{{ smtp.port }}"
    secure: "{{ smtp.secure }}"
    username: "{{ smtp.username }}"
    password: "{{ smtp.password }}"
    subtype: "html"
    from: "{{ email.from }}"
    to: "{{ to }}"
    subject: "{{ subject }}"
    body: "{{ body }}"
    attach: "{{ email.attach | default(omit) }}"
    headers:
      - X-Protective-Marking="VER=2005.6, NS=2020.1.example.com, SEC=xfkrf, ORIGIN=noreply@example.com"

The split("=") function applied to split the header key and value generate an error because there are multiples = characters, but only 2 output values are expected. Adding a maxsplit of 1 to the split fix the behavior and extract correctly the header key and value.

@ansibullbot
Copy link
Collaborator

@ansibullbot ansibullbot added WIP Work in progress bug This issue/PR relates to a bug module module needs_ci This PR requires CI testing to be performed. Please close and re-open this PR to trigger CI new_contributor Help guide this first time contributor plugins plugin (any type) labels Sep 21, 2023
@Theo024 Theo024 marked this pull request as ready for review September 21, 2023 17:05
@ansibullbot ansibullbot removed WIP Work in progress needs_ci This PR requires CI testing to be performed. Please close and re-open this PR to trigger CI labels Sep 21, 2023
Copy link
Collaborator

@felixfontein felixfontein left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution! I have one comment for the changelog fragment, besides that this is good!

@felixfontein felixfontein added check-before-release PR will be looked at again shortly before release and merged if possible. backport-6 labels Sep 22, 2023
Co-authored-by: Felix Fontein <felix@fontein.de>
@felixfontein felixfontein removed the check-before-release PR will be looked at again shortly before release and merged if possible. label Sep 22, 2023
@felixfontein felixfontein merged commit f4237dd into ansible-collections:main Sep 22, 2023
@patchback
Copy link

patchback bot commented Sep 22, 2023

Backport to stable-6: 💚 backport PR created

✅ Backport PR branch: patchback/backports/stable-6/f4237dde1bd0093438705edd52006cc40470dc45/pr-7303

Backported as #7305

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

@felixfontein
Copy link
Collaborator

@Theo024 thanks a lot for your contribution!

patchback bot pushed a commit that referenced this pull request Sep 22, 2023
* Fix incorrect parsing of header containing equal character

* Add changelog fragment

* Update changelogs/fragments/7303-mail-incorrect-header-parsing.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit f4237dd)
@patchback
Copy link

patchback bot commented Sep 22, 2023

Backport to stable-7: 💚 backport PR created

✅ Backport PR branch: patchback/backports/stable-7/f4237dde1bd0093438705edd52006cc40470dc45/pr-7303

Backported as #7306

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

patchback bot pushed a commit that referenced this pull request Sep 22, 2023
* Fix incorrect parsing of header containing equal character

* Add changelog fragment

* Update changelogs/fragments/7303-mail-incorrect-header-parsing.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit f4237dd)
felixfontein pushed a commit that referenced this pull request Sep 22, 2023
…rs containing equal character (#7305)

Fix incorrect parsing of headers containing equal character (#7303)

* Fix incorrect parsing of header containing equal character

* Add changelog fragment

* Update changelogs/fragments/7303-mail-incorrect-header-parsing.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit f4237dd)

Co-authored-by: Théo Lévesque <Theo024@users.noreply.github.com>
felixfontein pushed a commit that referenced this pull request Sep 22, 2023
…rs containing equal character (#7306)

Fix incorrect parsing of headers containing equal character (#7303)

* Fix incorrect parsing of header containing equal character

* Add changelog fragment

* Update changelogs/fragments/7303-mail-incorrect-header-parsing.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit f4237dd)

Co-authored-by: Théo Lévesque <Theo024@users.noreply.github.com>
etrombly pushed a commit to etrombly/community.general that referenced this pull request Oct 25, 2023
…collections#7303)

* Fix incorrect parsing of header containing equal character

* Add changelog fragment

* Update changelogs/fragments/7303-mail-incorrect-header-parsing.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Co-authored-by: Felix Fontein <felix@fontein.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue/PR relates to a bug module module new_contributor Help guide this first time contributor plugins plugin (any type)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants