# Url\_helper mail\_to escapes @ as %40 in cc and bcc elements

**URL:** <https://www.ruby-forum.com/t/url-helper-mail-to-escapes-as-40-in-cc-and-bcc-elements/183797>\
**Category:** Rails\
**Created:** [February 20, 2010, 12:19pm UTC](https://www.ruby-forum.com/t/url-helper-mail-to-escapes-as-40-in-cc-and-bcc-elements/183797 "2010-02-20T12:19:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![neil](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/839c29/32.png) [@neil](https://www.ruby-forum.com/u/neil)\
**Post date:** [February 20, 2010, 12:19pm UTC](https://www.ruby-forum.com/t/url-helper-mail-to-escapes-as-40-in-cc-and-bcc-elements/183797/1 "2010-02-20T12:19:00Z")

</div>

I’ve run into an annoying inconsistency between the mail\_to method’s  
documentation and its implementation. This would be an easy fix if  
the documentation was incorrect, but it seems that the implementation  
is the one using the wrong method.

Contrary to the documentation of url\_helper’s mailto, bcc and cc  
elements are CGI.escape()d, which seems to replace everything not  
alphanumeric with a %-encoding, including transforming @ to %40. This  
behavior is in contrast to what seems to be the original patch to  
enable cc and bcc handling, which called URI.escape.

[http://dev.rubyonrails.org/attachment/ticket/966/url\_helper.patch](http://dev.rubyonrails.org/attachment/ticket/966/url_helper.patch)

My read of a proto-specification of mailto ([http://ietfreport.isoc.org/](http://ietfreport.isoc.org/)  
idref/draft-duerst-mailto-bis/) suggests that @ signs are preferred;  
one of my users runs a client that choked on the %40. What I’d like  
to ask for is:

a) A suggestion as to how to override the behavior of mail\_to as a  
workaround. Effectively, where do I put a method named mail\_to ? and  
how do I invoke the original one before gsub(/%40/,‘@’))? Or should  
I freeze and edit?

b) A hint as to how to best submit a patch (or whether it’s worth  
writing one). Clearly the documentation of the method is inconsistent  
with its behavior. It looks like the original patch, when applied by  
david heinemeier hansson was transformed to use CGI.escape, that a  
test was written to check for %40 as the goal, but the documentation  
was left alone to imply that @ syntax would be used.

[http://sandbox.fisheye.atlassian.com/changelog/rails/?cs=f7c61b629e76e21ae78c6da3e9f6ee070d03bae8](http://sandbox.fisheye.atlassian.com/changelog/rails/?cs=f7c61b629e76e21ae78c6da3e9f6ee070d03bae8)

Help?
