/**
* mime.php
*
- * Copyright (c) 1999-2004 The SquirrelMail Project Team
+ * Copyright (c) 1999-2005 The SquirrelMail Project Team
* Licensed under the GNU GPL. For full terms see the file COPYING.
*
* This contains the functions necessary to detect and decode MIME
/* Don't kill the connection if the browser is over a dialup
* and it would take over 30 seconds to download it.
- * Dont call set_time_limit in safe mode.
+ * Don't call set_time_limit in safe mode.
*/
if (!ini_get('safe_mode')) {
* primary message. To add more of them, just put them in the
* order that is their priority.
*/
- global $startMessage, $username, $key, $imapServerAddress, $imapPort,
+ global $startMessage, $languages, $squirrelmail_language,
$show_html_default, $sort, $has_unsafe_images, $passed_ent_id;
- global $languages, $squirrelmail_language;
if( !sqgetGlobalVar('view_unsafe_images', $view_unsafe_images, SQ_GET) ) {
$view_unsafe_images = false;
function formatAttachments($message, $exclude_id, $mailbox, $id) {
- global $where, $what, $startMessage, $color;
- static $ShownHTML = 0;
+ global $where, $what, $startMessage, $color, $passed_ent_id;
$att_ar = $message->getAttachments($exclude_id);
$type0 = strtolower($header->type0);
$type1 = strtolower($header->type1);
$name = '';
- $links['download link']['text'] = _("download");
+ $links['download link']['text'] = _("Download");
$links['download link']['href'] = SM_PATH .
"src/download.php?absolute_dl=true&passed_id=$id&mailbox=$urlMailbox&ent_id=$ent";
- $ImageURL = '';
if ($type0 =='message' && $type1 == 'rfc822') {
$default_page = SM_PATH . 'src/read_body.php';
$rfc822_header = $att->rfc822_header;
if ($where && $what) {
$defaultlink .= '&where='. urlencode($where).'&what='.urlencode($what);
}
+
/* This executes the attachment hook with a specific MIME-type.
* If that doesn't have results, it tries if there's a rule
* for a more generic type.
function sqimap_base64_decode(&$string) {
- // base64 enoded data goes in pairs of 4 bytes. To achieve on the
+ // Base64 encoded data goes in pairs of 4 bytes. To achieve on the
// fly decoding (to reduce memory usage) you have to check if the
// data has incomplete pairs
- // remove the noise in order to check if the 4 bytes pairs are complete
+ // Remove the noise in order to check if the 4 bytes pairs are complete
$string = str_replace(array("\r\n","\n", "\r", " "),array('','','',''),$string);
$sStringRem = '';
$iMod = strlen($string) % 4;
if ($iMod) {
$sStringRem = substr($string,-$iMod);
- // check if $sStringRem contains padding characters
+ // Check if $sStringRem contains padding characters
if (substr($sStringRem,-1) != '=') {
$string = substr($string,0,-$iMod);
} else {
}
$iLastMatch = $i;
$j = $i;
- $ret .= $res[1];
+ if ($htmlsave) {
+ $ret .= htmlspecialchars($res[1]);
+ } else {
+ $ret .= $res[1];
+ }
$encoding = ucfirst($res[3]);
/* decide about valid decoding */
{
case 'B':
$replace = base64_decode($res[4]);
- if ($can_be_encoded) {
- /* convert string to different charset,
- * if functions asks for it (usually in compose)
- */
- $ret .= charset_convert($res[2],$replace,$default_charset);
+ if ($utfencode) {
+ if ($can_be_encoded) {
+ /* convert string to different charset,
+ * if functions asks for it (usually in compose)
+ */
+ $ret .= charset_convert($res[2],$replace,$default_charset);
+ } else {
+ // convert string to html codes in order to display it
+ $ret .= charset_decode($res[2],$replace);
+ }
} else {
- // convert string to html codes in order to display it
- $ret .= charset_decode($res[2],$replace);
+ if ($htmlsave) {
+ $replace = htmlspecialchars($replace);
+ }
+ $ret.= $replace;
}
break;
case 'Q':
* 2. Closing tag, e.g.:
* </a>
* 3. XHTML-style content-less tag, e.g.:
- * <img src="blah"/>
+ * <img src="blah" />
*/
$tagtype = false;
switch (substr($body, $pos, 1)){
break;
}
- $tag_start = $pos;
$tagname = '';
/**
* Look for next [\W-_], which will indicate the end of the tag name.
case '/':
/**
* This is an xhtml-style tag with a closing / at the
- * end, like so: <img src="blah"/>. Check if it's followed
+ * end, like so: <img src="blah" />. Check if it's followed
* by the closing bracket. If not, then this tag is invalid
*/
if (substr($body, $pos, 2) == "/>"){
* At this point we loop in order to find all attributes.
*/
$attname = '';
- $atttype = false;
$attary = Array();
while ($pos <= strlen($body)){
case '/':
/**
* This is an xhtml-style tag with a closing / at the
- * end, like so: <img src="blah"/>. Check if it's followed
+ * end, like so: <img src="blah" />. Check if it's followed
* by the closing bracket. If not, then this tag is invalid
*/
if (substr($body, $pos, 2) == "/>"){
function sq_body2div($attary, $mailbox, $message, $id){
$me = 'sq_body2div';
$divattary = Array('class' => "'bodyclass'");
- $bgcolor = '#ffffff';
$text = '#000000';
$has_bgc_stl = $has_txt_stl = false;
$styledef = '';
// version
//set all the Cache Control Headers for IE
if ($isIE) {
+ $filename=urlencode($filename);
header ("Pragma: public");
header ("Cache-Control: no-store, max-age=0, no-cache, must-revalidate"); # HTTP/1.1
header ("Cache-Control: post-check=0, pre-check=0", false);