Skip to content

Percent-encode unsafe characters in a mailto address - #277

Open
adityawrk wants to merge 1 commit into
ruby:masterfrom
adityawrk:fix/mailto-percent-encode
Open

adityawrk wants to merge 1 commit into
ruby:masterfrom
adityawrk:fix/mailto-percent-encode

Conversation

@adityawrk

@adityawrk adityawrk commented Nov 29, 2026 •

Copy link
Copy Markdown

Fixes #238.

URI::MailTo.build copied the address into the URI unchanged. An address such as #!$%&'*+-/=?^_\{}|@example.orgthen failed withunrecognised opaque part for mailtoURL, because ?` starts the header section and several other characters are not allowed raw in the address.

Those octets are now percent-encoded when the address is built. An existing percent-escape is left alone, so gorby%25kremvax@example.com is not encoded twice. + is also left as-is: RFC 6068 says it MAY be encoded, and it is the usual subaddress form (foo+@example.com).

URI tests: 95 tests, 0 failures.

MailTo.build copied the address into the URI unchanged, so a reserved
character such as ? or # made the address fail to parse. Those octets
are now percent-encoded. A plus sign is left as-is, because RFC 6068
uses it for subaddresses.

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.

URI::MailTo.build does not percent-encode addresses (contrary to RFC 6068)

1 participant