summaryrefslogtreecommitdiff
path: root/inc
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2013-10-22 20:55:21 +0200
committerAndreas Gohr <andi@splitbrain.org>2013-10-22 20:55:54 +0200
commit1d8036c2a36d5e226e4a58657e9d859cbc241508 (patch)
tree7c00e10b8bd39f6bf54baa5020f297c744a7dcb3 /inc
parentd305bc7eb3852eee783d22481decd171c2ce044c (diff)
downloadrpg-1d8036c2a36d5e226e4a58657e9d859cbc241508.tar.gz
rpg-1d8036c2a36d5e226e4a58657e9d859cbc241508.tar.bz2
Mailer: avoid overlong headers in content ids FS#2868
Diffstat (limited to 'inc')
-rw-r--r--inc/Mailer.class.php30
1 files changed, 18 insertions, 12 deletions
diff --git a/inc/Mailer.class.php b/inc/Mailer.class.php
index 6a6468ab4..186bd531a 100644
--- a/inc/Mailer.class.php
+++ b/inc/Mailer.class.php
@@ -43,7 +43,7 @@ class Mailer {
$server = parse_url(DOKU_URL, PHP_URL_HOST);
if(strpos($server,'.') === false) $server = $server.'.localhost';
- $this->partid = md5(uniqid(rand(), true)).'@'.$server;
+ $this->partid = substr(md5(uniqid(rand(), true)),0, 8).'@'.$server;
$this->boundary = '__________'.md5(uniqid(rand(), true));
$listid = join('.', array_reverse(explode('/', DOKU_BASE))).$server;
@@ -430,14 +430,13 @@ class Mailer {
}
$mime .= '--'.$this->boundary.MAILHEADER_EOL;
- $mime .= 'Content-Type: '.$media['mime'].';'.MAILHEADER_EOL.
- ' id="'.$cid.'"'.MAILHEADER_EOL;
- $mime .= 'Content-Transfer-Encoding: base64'.MAILHEADER_EOL;
- $mime .= "Content-ID: <$cid>".MAILHEADER_EOL;
+ $mime .= $this->wrappedHeaderLine('Content-Type', $media['mime'].'; id="'.$cid.'"');
+ $mime .= $this->wrappedHeaderLine('Content-Transfer-Encoding', 'base64');
+ $mime .= $this->wrappedHeaderLine('Content-ID',"<$cid>");
if($media['embed']) {
- $mime .= 'Content-Disposition: inline; filename='.$media['name'].''.MAILHEADER_EOL;
+ $mime .= $this->wrappedHeaderLine('Content-Disposition', 'inline; filename='.$media['name']);
} else {
- $mime .= 'Content-Disposition: attachment; filename='.$media['name'].''.MAILHEADER_EOL;
+ $mime .= $this->wrappedHeaderLine('Content-Disposition', 'attachment; filename='.$media['name']);
}
$mime .= MAILHEADER_EOL; //end of headers
$mime .= chunk_split(base64_encode($media['data']), 74, MAILHEADER_EOL);
@@ -556,10 +555,17 @@ class Mailer {
}
}
- // wrap headers
- foreach($this->headers as $key => $val) {
- $this->headers[$key] = wordwrap($val, 78, MAILHEADER_EOL.' ');
- }
+ }
+
+ /**
+ * Returns a complete, EOL terminated header line, wraps it if necessary
+ *
+ * @param $key
+ * @param $val
+ * @return string
+ */
+ protected function wrappedHeaderLine($key, $val){
+ return wordwrap("$key: $val", 78, MAILHEADER_EOL.' ').MAILHEADER_EOL;
}
/**
@@ -571,7 +577,7 @@ class Mailer {
$headers = '';
foreach($this->headers as $key => $val) {
if ($val === '') continue;
- $headers .= "$key: $val".MAILHEADER_EOL;
+ $headers .= $this->wrappedHeaderLine($key, $val);
}
return $headers;
}