Rails 2 Mailer View在字符串之前添加3D [英] Rails 2 Mailer View Prepending 3D to strings

查看:52
本文介绍了Rails 2 Mailer View在字符串之前添加3D的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个非常老的Rails应用程序,它试图为新用户发送验证电子邮件,但始终找不到令牌,因为无论出于何种原因,无论我如何生成链接,链接都会在字符串中添加3D前缀。出于某种原因,它似乎还向令牌中间注入了=符号。

I have a very old rails app that is trying to send verification emails for new users but the token can never be found because for some reason the link gets 3D prepended to the string no matter how I generate the link. It also seems to be injecting an = sign into the middle of the token for some reason.

以下是输出代码:

<%= link_to verify_account_url(:host => (ActionMailer::Base.default_url_options[:host] || ''), :t => @token), verify_account_url(:host => (ActionMailer::Base.default_url_options[:host] || ''), :t => @token) %>

<a href=3D"https://localhost:3000/accounts/verify?t=3Dd486da2ac8a6dea8a3d9ce341c7aa6=
b01cca96ea">https://localhost:3000/accounts/verify?t=3Dd486da2ac8a6dea8a3d9ce341c7aa6b0=
1cca96ea</a>

,数据库中的令牌为:

#<AccountToken id: 6317, token: "d486da2ac8a6dea8a3d9ce341c7aa6b01cca96ea", email: "...", client: nil>

我也尝试过硬编码URL并在字符串输出中插入令牌,但是同样的问题正在发生,对于普通的HTML标签,似乎也发生了这种情况:

I've also tried just hardcoding the URL and interpolating the token in the string output but the same issue is happening, it also appears to happen for normal HTML tags as such:

<p style="margin: 0 0 1em;">If clicking the link doesn't work, copy and paste the link into your browser's address bar.</p>

结果

<p style=3D"margin: 0 0 1em;">If clicking the link doesn't work, copy a=nd paste the link into your browser's address bar.</p>

有人有什么想法吗?

推荐答案

这很正常。为了使电子邮件顺利通过可能仅支持7位ascii的旧系统,电子邮件正文经常使用各种将所有内容都转换为7位ascii的方案进行编码。

This is normal. In order for email to travel smoothly through legacy systems that might only support 7bit ascii email bodies are often encoding using various schemes that convert everything to 7bit ascii.

称为quoted-printable,在此方案中,特殊字符使用 = 进行编码,后跟十六进制字节值(与url中的%编码基本相同)。该方案的一部分是,行的长度不得超过76个字符-如果插入的行较长,则应包含回车符以及 = ,以便可以区分这些字符

One such scheme is called quoted-printable, in this scheme special characters are encoded using = followed by the hex byte value (basically the same as % encoding in urls). Part of this scheme is that lines have to be no longer than 76 characters - if a line is longer a carriage return is inserted, along with an = so that these can be distinguished from line breaks present in the source document.

当邮件客户端读取电子邮件时,那些额外的 = 和行返回将不再存在。

When the email is read by a mail client those extra = and line returns won't be there anymore.

这篇关于Rails 2 Mailer View在字符串之前添加3D的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆