You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
URI::MailTo.build does not percent-encode addresses (contrary to RFC 6068) #238
URI::MailTo raises InvalidComponentError when given these special symbols, which RFC 6068, section 2 requires be percent-encoded.
URI::MailTo.build(to: "#!$%&'*+-/=?^_`{}|@example.org")# unrecognised opaque part for mailtoURL: #!$%&'*+-/=?^_`{}|@example.org (URI::InvalidComponentError)# expected: mailto:%23%21%24%25%26%27%2A%2B-%2F%3D%3F%5E_%60%7B%7D%7C@example.org
For reference, see this PR which implemented this behaviour in Rails' ActionView (though Rails has its own URI generation logic, and doesn't use URI::MailTo).
This logic was last changed back in 2014 in 3fdc4b6
One thing to settle first: build currently passes to through as already-encoded, e.g. build(to: "a%2Bb@example.org") gives mailto:a%2Bb@example.org. If build starts encoding everything, that input would become a%252Bb, which breaks anyone escaping on their side.
My plan is to percent-encode only the characters that aren't allowed in to, and leave existing %XX sequences alone, so current callers keep working. A literal % that isn't followed by two hex digits would become %25. Does that sound OK, or would you rather have an option/new method for it?
Activity
sourya2704 commentedon Oct 18, 2026
I'd like to work on this if nobody else is.
One thing to settle first:
buildcurrently passestothrough as already-encoded, e.g.build(to: "a%2Bb@example.org")givesmailto:a%2Bb@example.org. Ifbuildstarts encoding everything, that input would becomea%252Bb, which breaks anyone escaping on their side.My plan is to percent-encode only the characters that aren't allowed in
to, and leave existing%XXsequences alone, so current callers keep working. A literal%that isn't followed by two hex digits would become%25. Does that sound OK, or would you rather have an option/new method for it?