Special chars in email are escaped using HTML entities

mygumbo - June 1, 2007 - 01:22
Project:Notify
Version:5.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:patch (reviewed & tested by the community)
Description

I've got a drupal site name that has a single quote in it, e.g. Foo's Bar. When notify sends an email, otherwise working great, the subject line is Foo's Bar new content notification for admin.

#1

mygumbo - June 1, 2007 - 01:27

Argh. It shows up as

Foo&#039 ;s Bar

#2

nicokarp - June 25, 2007 - 14:33

I had similar behaviour with single quotes within title (nodes or comments).
I did a little hack by replacing a line in notify.module :
"$body = $node_body . $comment_body;"
to
"$body = notify_entities_to_utf8($node_body . $comment_body);"

For your problem, same thing could be done for the variable $subject

I did this very quickly... working for me but not clean (newbie as i am).

#3

martinship - March 19, 2008 - 08:09
Priority:minor» normal

Single quotes aren& #039;t the only problem: that& #039;s the apostrophe too. It& #039;s visually ugly to say the least. Since contractions are pretty common, I& #039;d say this is a normal bug, not a & #039;minor& #039; one. I& #039;m sure you see my point.

Sorry, I& #039;ve just seen this in all my notification emails and it& #039;s driving me nuts ...

#4

gracearoha - April 26, 2008 - 04:06

I also have this problem with double quotes showing up like: "My Pages"

this is also driving me crazy. Has anyone found a solution to these odditites?

#5

mErilainen - August 27, 2008 - 09:51

I have the same problem. First I thought it has something to do with FCKeditor, but it doesn't. Email notifications for Organic Groups are pretty much unusable, as single quote is quite common character.

#6

Standart - August 28, 2008 - 09:50
Title:Site name with single quote» Special chars in email are escaped using HTML entities
Version:5.x-1.0» 5.x-1.x-dev

Many variables like sitename, title, author, etc are run through htmlspecialchars() which encodes '&', '"', ''', '<', and '>'. This makes sense if you're displaying the variables in HTML which we don't do here. The escaping takes place because of the usage of the '@' decorator for variables in the t()-function which in turn uses check_plain() which contains htmlspecialchars(). The docs say that you should use the '!' decorator for variables supposed to appear in an email (http://api.drupal.org/api/function/t/5). Why does notify use '@'? Also a statement like

<?php
  t
('@title', array('@title' => $node->title))
?>

doesn't make much senseto me as you translate a varibale only which is the same as doing

<?php
  check_plain
($node->title);
?>

if I understand this correctly. Shouldn't we change all decorators from '@' to '!' in t() and also remove statements like the one above completely (we don't need to check for security in an HTML context at all, do we)?

#7

matt2000 - August 28, 2008 - 16:30

I've noticed this issue while I've been doing some work on making messages templatable in notify by views.

If someone can provide a patch for notify, I'll apply it & release, but if I have to do it myself, I may not get to it for a little while yet.

#8

Standart - August 30, 2008 - 14:30
Status:active» patch (code needs review)

Attached is my patch against 5.x-1.x-dev. I replaced all @ decorators with !. Also I removed the empty t() for the item title.

AttachmentSize
notify-5-148454-1.patch5.62 KB

#9

matt2000 - August 30, 2008 - 14:47
Status:patch (code needs review)» fixed

Initial glance at patch look good, so it's been applied to -dev branch.

Please test & report back.

#10

matt2000 - August 30, 2008 - 14:58

Also applied to 6.x -dev branch.

#11

Standart - August 31, 2008 - 19:25

Please apply it to the 5.x-dev branch, too.

#12

matt2000 - September 3, 2008 - 05:19

Hmm... trying to figure out what happened to the tagging with this module.

In the meantime, a 5.x release is here: http://drupal.org/node/303336

#13

Anonymous (not verified) - September 17, 2008 - 05:22
Status:fixed» closed

Automatically closed -- issue fixed for two weeks with no activity.

#14

Standart - September 17, 2008 - 09:09
Status:closed» patch (reviewed & tested by the community)

Please apply to the 5.x-1.x branch and make a new release 5.x-1.2.

 
 

Drupal is a registered trademark of Dries Buytaert.