Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormattab <matthieu.aubry@gmail.com>2016-01-26 09:06:26 +0300
committermattab <matthieu.aubry@gmail.com>2016-01-26 09:06:26 +0300
commit619ac550706ac4cb3e68f01a6eda60da3d038180 (patch)
tree7083c7ebb14d0c238280180aa29ef09b4885baa9 /core/Mail.php
parent531c9b51db6db054d23b1d55a90792e2d6c7ce7d (diff)
Replace some characters in Email subject and Email attachments filename
Fixes #9631
Diffstat (limited to 'core/Mail.php')
-rw-r--r--core/Mail.php26
1 files changed, 26 insertions, 0 deletions
diff --git a/core/Mail.php b/core/Mail.php
index 454fcd377c..192c5a94e5 100644
--- a/core/Mail.php
+++ b/core/Mail.php
@@ -127,6 +127,18 @@ class Mail extends Zend_Mail
}
}
+ public function createAttachment($body, $mimeType = null, $disposition = null, $encoding = null, $filename = null)
+ {
+ $filename = self::sanitiseString($filename);
+ return parent::createAttachment($body, $mimeType, $disposition, $encoding, $filename);
+ }
+
+ public function setSubject($subject)
+ {
+ $subject = self::sanitiseString($subject);
+ return parent::setSubject($subject);
+ }
+
/**
* @param string $email
* @return string
@@ -154,4 +166,18 @@ class Mail extends Zend_Mail
{
return isset($url['host']) && !Url::isLocalHost($url['host']);
}
+
+ /**
+ * Replaces characters known to appear incorrectly in some email clients
+ *
+ * @param $string
+ * @return mixed
+ */
+ static public function sanitiseString($string)
+ {
+ $search = array('–', '’');
+ $replace = array('-', '\'');
+ $string = str_replace($search, $replace, $string);
+ return $string;
+ }
}