Skip to content

Fix URI::MailTo#to_mailtext with a header without value - #264

Open
afurm wants to merge 1 commit into
ruby:masterfrom
afurm:fix-mailto-to-mailtext-nil-header
Open

afurm wants to merge 1 commit into
ruby:masterfrom
afurm:fix-mailto-to-mailtext-nil-header

Conversation

@afurm

@afurm afurm commented Oct 12, 2026

Copy link
Copy Markdown
Member

URI.parse("mailto:ruby-list@ruby-lang.org?Subject").to_mailtext raises NoMethodError because a header with no value is stored as ["Subject"] and then decoded as nil.

I updated set_headers to use "" for missing values, and to_mailtext stringifies so a nil address is treated as empty. I also added a test for this case.

URI.parse accepts query headers without a value (for example
?Subject or ?body&cc=...), so set_headers stored a one-element
array. to_mailtext then called decode_www_form_component(nil) and
raised NoMethodError.

Normalize missing header values to "" when parsing, and treat a
nil to address as empty when building the mailtext.

This branch has not been deployed

No deployments
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

Successfully merging this pull request may close these issues.

1 participant