我在 notifier_test.rb 中有一个测试,其中 Notifier 是我的邮件程序类
mail = Notifier.registered_client(client.firstname, client.emailaddress)
assert_match I18n.t('notifier.registered_client.email_body'), mail.body.encoded, 'Email contents should be correct'
该测试在 Rails 3.2.8 之前通过,但现在测试失败:
NotifierTest
FAIL (0:00:07.963) should create registration email in English
Email contents should be correct.
Expected /In\ order\ to\ activate\ your\ company's\ registration\ you\ must\ click\ on\ the\ following\ link:/
to match
"\nDear First Name, thanks for registering.\n\nIn order to activate your company\'s registration you must click on the following link:\n\nhttp://localhost:3000/en/clients/activate?email=english%40email.com&key=7b6e6ed1-ac03-4d95-a0d5-6f2541092dd0\n".
似乎出现了错误,因为我的邮件文本包含一个撇号,mail.body.encoded
现在\'
由于以下补丁而返回:
CVE-2012-3464 在https://groups.google.com/forum/#!msg/rubyonrails-security/kKGNeMrnmiY/r2yM7xy-G48J中描述的 Ruby on Rails 中的潜在 XSS 漏洞
以相同方式对 I18n.t 返回的字符串进行编码,或者从我的邮件对象中获取没有撇号的文本的最聪明的方法是什么?