diff --git a/inc/common.php b/inc/common.php
index ac7e744d8eb7d08bac9faad70d85c8733fa09c53..20baed6c01ca96f71640859d5371dd7396ef2324 100644
--- a/inc/common.php
+++ b/inc/common.php
@@ -1150,14 +1150,18 @@ function notify($id, $who, $rev = '', $summary = '', $minor = false, $replace =
     } elseif($rev) {
         $subject         = $lang['mail_changed'].' '.$id;
         $trep['OLDPAGE'] = wl($id, "rev=$rev", true, '&');
-        $df              = new Diff(explode("\n", rawWiki($id, $rev)),
-                                    explode("\n", rawWiki($id)));
+        $old_content     = rawWiki($id, $rev);
+        $new_content     = rawWiki($id);
+        $df              = new Diff(explode("\n", $old_content),
+                                    explode("\n", $new_content));
         $dformat         = new UnifiedDiffFormatter();
         $tdiff           = $dformat->format($df);
 
         $DIFF_INLINESTYLES = true;
+        $hdf               = new Diff(explode("\n", hsc($old_content)),
+                                      explode("\n", hsc($new_content)));
         $dformat           = new InlineDiffFormatter();
-        $hdiff             = $dformat->format($df);
+        $hdiff             = $dformat->format($hdf);
         $hdiff             = '<table>'.$hdiff.'</table>';
         $DIFF_INLINESTYLES = false;
     } else {