alecpl
2008-06-16 5f8686e28e4acad3f196fd531a9a102291dbf448
#1484423: add <head> for malformed messages, washtml cannot work without that


1 files modified
6 ■■■■ changed files
program/steps/mail/func.inc 6 ●●●● patch | view | raw | blame | history
program/steps/mail/func.inc
@@ -538,8 +538,12 @@
    $html = $part->body; 
    if(preg_match('/(\s+content=[\'"]\w+\/\w+;\s+charset)=([a-z0-9-]+)/i', $html)) 
      $html = preg_replace('/(\s+content=[\'"]\w+\/\w+;\s+charset)=([a-z0-9-]+)/i', '\\1='.RCMAIL_CHARSET, $html); 
    else
    else {
      // add <head> for malformed messages, washtml cannot work without that
      if (!preg_match('/<head>(.*)<\/head>/m', $html))
        $html = '<head></head>' . $html;
      $html = substr_replace($html, '<meta http-equiv="Content-Type" content="text/html; charset='.RCMAIL_CHARSET.'" />', intval(stripos($html, '</head>')), 0);
    }
    
    // clean HTML with washhtml by Frederic Motte
    $body = washtml::wash($html, array(