Index: /branches/2.2/expressoMail1_2/inc/class.imap_functions.inc.php
===================================================================
--- /branches/2.2/expressoMail1_2/inc/class.imap_functions.inc.php	(revision 3352)
+++ /branches/2.2/expressoMail1_2/inc/class.imap_functions.inc.php	(revision 3369)
@@ -1809,5 +1809,5 @@
 		##
 		# @AUTHOR Rodrigo Souza dos Santos
-		# @DATE 2008/09/17
+		# @DATE 2008/09/17$fileName
 		# @BRIEF Checks if the user has permission to send an email with the email address used.
 		##
@@ -1879,5 +1879,5 @@
 		$forwarding_attachments = $params['forwarding_attachments'];
 		$local_attachments = $params['local_attachments'];
-		
+
 		//Test if must be saved in shared folder and change if necessary
 		if( $fromaddress[2] == 'y' ){
@@ -2074,5 +2074,5 @@
 					$fileName = $file_description[2];
 					if(!array_search(trim($fileName),$name_cid_files)) {
-						$mail->AddStringAttachment($fileContent, $fileName, $file_description[4], $this->get_file_type($file_description[2]));
+						$mail->AddStringAttachment($fileContent,html_entity_decode(rawurldecode($fileName)), $file_description[4], $this->get_file_type($file_description[2]));
 				}
 			}
Index: /branches/2.2/expressoMail1_2/inc/gotodownload.php
===================================================================
--- /branches/2.2/expressoMail1_2/inc/gotodownload.php	(revision 3240)
+++ /branches/2.2/expressoMail1_2/inc/gotodownload.php	(revision 3369)
@@ -12,5 +12,5 @@
 	$msg_number = $_GET['msg_number'];
 	$idx_file = $_GET['idx_file'];
-	$newfilename = urldecode($_GET['newfilename']);
+        $newfilename = html_entity_decode(rawurldecode($_GET['newfilename']));
 	$msg_part = $_GET['msg_part'];
 	$msg_folder = $_GET['msg_folder'];
@@ -24,5 +24,5 @@
 		$password = $_SESSION['phpgw_info']['expressomail']['user']['passwd'];
 		$imap_server = $_SESSION['phpgw_info']['expressomail']['email_server']['imapServer'];
-		$imap_port 	= $_SESSION['phpgw_info']['expressomail']['email_server']['imapPort'];		
+		$imap_port 	= $_SESSION['phpgw_info']['expressomail']['email_server']['imapPort'];
 		if ($_SESSION['phpgw_info']['expressomail']['email_server']['imapTLSEncryption'] == 'yes')
 		{
@@ -33,10 +33,10 @@
 			$imap_options = '/notls/novalidate-cert';
 		}
-		$mbox_stream = imap_open("{".$imap_server.":".$imap_port.$imap_options."}".$msg_folder, $username, $password);   	
+		$mbox_stream = imap_open("{".$imap_server.":".$imap_port.$imap_options."}".$msg_folder, $username, $password);
 		$fileContent = imap_fetchbody($mbox_stream, $msg_number, $msg_part, FT_UID);
 		/*
 		 *Removed by Bug #546
 		 *include("class.imap_attachment.inc.php");
-		 *$imap_attachment = new imap_attachment();	   		
+		 *$imap_attachment = new imap_attachment();
 		 *$a = $imap_attachment->download_attachment($mbox_stream, $msg_number);
 		 *$filename = $a[$idx_file]['name'];
@@ -54,9 +54,9 @@
 
 	function downloadFile($strFileType, $strFileName, $newFileName, $fileContent, $encoding) {
-		//avoid stuck request 
-		session_write_close(); 
+		//avoid stuck request
+		session_write_close();
 		$ContentType = "application/octet-stream";
 
-		if ($strFileType == ".asf") 
+		if ($strFileType == ".asf")
 			$ContentType = "video/x-ms-asf";
 		if ($strFileType == ".avi")
@@ -82,13 +82,13 @@
 		if ($strFileType == ".htm" || $strFileType == "html")
 			$ContentType = "text/html";
-		if ($strFileType == ".xml") 
+		if ($strFileType == ".xml")
 			$ContentType = "text/xml";
-		if ($strFileType == ".xsl") 
+		if ($strFileType == ".xsl")
 			$ContentType = "text/xsl";
-		if ($strFileType == ".css") 
+		if ($strFileType == ".css")
 			$ContentType = "text/css";
-		if ($strFileType == ".php") 
+		if ($strFileType == ".php")
 			$ContentType = "text/php";
-		if ($strFileType == ".asp") 
+		if ($strFileType == ".asp")
 			$ContentType = "text/asp";
 		if ($strFileType == ".pdf")
@@ -161,5 +161,5 @@
 		header("Pragma: public");
 		header("Expires: 0"); // set expiration time
-		header ("Content-Disposition: attachment; filename=\"". addslashes($newFileName)."\"");   	
+		header ("Content-Disposition: attachment; filename=\"". addslashes($newFileName)."\"");
 		if($fileContent) {
 			if($encoding == 'base64')
Index: /branches/2.2/expressoMail1_2/js/common_functions.js
===================================================================
--- /branches/2.2/expressoMail1_2/js/common_functions.js	(revision 3336)
+++ /branches/2.2/expressoMail1_2/js/common_functions.js	(revision 3369)
@@ -35,13 +35,13 @@
 function resizeWindow(){
 
-	var divScrollMain = Element("divScrollMain_"+numBox); 
-	var table_message = Element("table_message"); 
-	var content_folders = Element("content_folders"); 
-	var clientHeight = ((window.innerHeight ? window.innerHeight : document.body.offsetHeight) - 8); 
+	var divScrollMain = Element("divScrollMain_"+numBox);
+	var table_message = Element("table_message");
+	var content_folders = Element("content_folders");
+	var clientHeight = ((window.innerHeight ? window.innerHeight : document.body.offsetHeight) - 8);
 	var clientWidth = window.innerWidth ? window.innerWidth : document.body.offsetWidth;
 
-	if(divScrollMain){ 
-		divScrollMain.style.height = (clientHeight - (findPosY(divScrollMain) + (table_message.clientHeight ? table_message.clientHeight : table_message.offsetHeight))) + "px"; 
-	} 
+	if(divScrollMain){
+		divScrollMain.style.height = (clientHeight - (findPosY(divScrollMain) + (table_message.clientHeight ? table_message.clientHeight : table_message.offsetHeight))) + "px";
+	}
 
 	if(typeof(BordersArray) != 'undefined') {
@@ -50,20 +50,20 @@
 			var div = Element("content_id_"+BordersArray[i].sequence);
 
-			if(div){ 
-				div.style.height = (clientHeight - (findPosY(div) + (table_message.clientHeight ? table_message.clientHeight : table_message.offsetHeight)+2)) + "px"; 
-				 div.style.width = (clientWidth - (findPosX(div)+10)) + "px"; 
-			} 
-			if(div_scroll){ 
-				div_scroll.style.height = (clientHeight - (findPosY(div_scroll) + (table_message.clientHeight ? table_message.clientHeight : table_message.offsetHeight)+5)) + "px"; 
-				div_scroll.style.width = (clientWidth - (findPosX(div_scroll)+15)) + "px"; 
-			} 
-		} 
-	} 
-
-	if(content_folders){ 
-		var search_div = Element("search_div"); 
-		var contentFoldersY = findPosY(content_folders); 
-		content_folders.style.height = (clientHeight - (contentFoldersY + (contentFoldersY > findPosY(search_div) ? 0 : (search_div.clientHeight ? search_div.clientHeight : search_div.offsetHeight) + 5))) + "px"; 
-	} 
+			if(div){
+				div.style.height = (clientHeight - (findPosY(div) + (table_message.clientHeight ? table_message.clientHeight : table_message.offsetHeight)+2)) + "px";
+				 div.style.width = (clientWidth - (findPosX(div)+10)) + "px";
+			}
+			if(div_scroll){
+				div_scroll.style.height = (clientHeight - (findPosY(div_scroll) + (table_message.clientHeight ? table_message.clientHeight : table_message.offsetHeight)+5)) + "px";
+				div_scroll.style.width = (clientWidth - (findPosX(div_scroll)+15)) + "px";
+			}
+		}
+	}
+
+	if(content_folders){
+		var search_div = Element("search_div");
+		var contentFoldersY = findPosY(content_folders);
+		content_folders.style.height = (clientHeight - (contentFoldersY + (contentFoldersY > findPosY(search_div) ? 0 : (search_div.clientHeight ? search_div.clientHeight : search_div.offsetHeight) + 5))) + "px";
+	}
 	redim_borders(count_borders());
 }
@@ -95,6 +95,6 @@
 // Translate words and phrases using user language from eGroupware.
 function get_lang(_key) {
-	if (typeof(_key) == 'undefined') 
-		return false; 
+	if (typeof(_key) == 'undefined')
+		return false;
 	var key = _key.toLowerCase();
 	if(array_lang[key])
@@ -116,5 +116,5 @@
 
 // Change the class of message.
-// In refresh, the flags UnRead and UnSeen don't exist anymore. 
+// In refresh, the flags UnRead and UnSeen don't exist anymore.
 function set_msg_as_read(msg_number, selected){
 	tr_message = Element(msg_number);
@@ -123,5 +123,5 @@
 	remove_className(tr_message, 'tr_msg_unread');
 	remove_className(tr_message, 'selected_msg');
-	Element("td_message_unseen_"+msg_number).innerHTML = "<img src ='templates/"+template+"/images/seen.gif' title='"+get_lang('Seen')+"'>"; 
+	Element("td_message_unseen_"+msg_number).innerHTML = "<img src ='templates/"+template+"/images/seen.gif' title='"+get_lang('Seen')+"'>";
 	connector.purgeCache();
 	return true;
@@ -136,8 +136,8 @@
 	tr_message = Element(msg_number);
 	if ((exist_className(tr_message, 'tr_msg_read') || exist_className(tr_message, 'tr_msg_read2')) && (!exist_className(tr_message, 'tr_msg_unread')))
-		increment_folder_unseen();	
+		increment_folder_unseen();
 	remove_className(tr_message, 'selected_msg');
 	add_className(tr_message, 'tr_msg_unread');
-	Element("td_message_unseen_"+msg_number).innerHTML = "<img src ='templates/"+template+"/images/unseen.gif' title='"+get_lang('Unseen')+"'>"; 
+	Element("td_message_unseen_"+msg_number).innerHTML = "<img src ='templates/"+template+"/images/unseen.gif' title='"+get_lang('Unseen')+"'>";
 }
 
@@ -197,8 +197,8 @@
 	//Get element tBody.
 	main = document.getElementById("tbody_box");
-		
+
 	// Get all TR (messages) in tBody.
 	main_list = main.childNodes;
-	
+
 	return main_list.length;
 }
@@ -218,5 +218,5 @@
 	div_attachment = document.getElementById("id_div_attachment");
 	var params = '';
-	
+
 	if (div_attachment == null){
 		var div_attachment = document.createElement("DIV");
@@ -233,5 +233,5 @@
 
 function download_all_attachments(msg_folder, msg_number){
-	var handler_source = function(data){		
+	var handler_source = function(data){
 		download_attachments(null, null, data, null,null,'anexos.zip');
 	}
@@ -244,5 +244,5 @@
 	if (! divFiles)
 		return false;
-	
+
 	if (divFiles.lastChild)
 		var countDivFiles = parseInt(divFiles.lastChild.id.split('_')[2]) + 1;
@@ -250,15 +250,15 @@
 	if (! countDivFiles)
 		var countDivFiles = 1;
-	
+
 	divFile = document.createElement('DIV');
-	
+
 
 	if (!expresso_offline) {
 		if (!is_ie) {
 			var inputFile = document.createElement("INPUT");
-			
+
 			var tmp_id_border = document.createAttribute('id_border');
 			tmp_id_border.value = id_border;
-			
+
 			inputFile.setAttributeNode(tmp_id_border);
 			inputFile.id = "inputFile_" + id_border + "_" + countDivFiles;
@@ -271,15 +271,15 @@
 		else {
 			var inputFile = document.createElement("link");
-			
+
 			var tmp_id_border = document.createAttribute('id_border');
 			tmp_id_border.value = id_border;
-			
+
 			inputFile.setAttributeNode(tmp_id_border);
 			inputFile.id = "inputFile_" + id_border + "_" + countDivFiles;
 			inputFile.name = 'file_' + countDivFiles;
-			
-			
-		}
-		
+
+
+		}
+
 	}
 	else {
@@ -287,5 +287,5 @@
 		inputFile.type = 'hidden';
 		inputFile.name = 'offline_forward_' + countDivFiles;
-	}	
+	}
 	divFile.appendChild(inputFile);
 
@@ -299,16 +299,16 @@
 	checkbox.id = "checkbox_"+id_border+"_"+countDivFiles;
 	checkbox.name = "local_attachments[]";
-	
+
 	checkbox.value = s_tmp;
 	divFile.appendChild(checkbox);
-	
+
 	var link_attachment = document.createElement("A");
 	link_attachment.setAttribute("href", link);
-	
+
 	link_attachment.innerHTML = file_name;
 	divFile.appendChild(link_attachment);
-	
+
 	countDivFiles++;
-	divFile.id = "divFile_"+id_border+"_"+countDivFiles;	
+	divFile.id = "divFile_"+id_border+"_"+countDivFiles;
 	divFiles.appendChild(divFile);
 
@@ -322,5 +322,5 @@
 	if (! divFiles)
 		return false;
-	
+
 	if (divFiles.lastChild)
 		var countDivFiles = parseInt(divFiles.lastChild.id.split('_')[2]) + 1;
@@ -328,22 +328,22 @@
 	if (! countDivFiles)
 		var countDivFiles = 1;
-	
+
 	divFile = document.createElement('DIV');
-	
-	
+
+
 	divFile.innerHTML = "<input type='file' id_border='"+id_border+"' size='50' maxLength='255' onchange=\"function () {validateFileExtension(this.value, this.id.replace('input','div'), this.getAttribute('id_border'));};\" id='"+"inputFile_"+id_border+"_"+countDivFiles+"' name='file_"+countDivFiles+"'>";
 
-	
+
 	var linkFile = document.createElement("A");
 	linkFile.id = "linkFile_"+id_border+"_"+countDivFiles;
 	linkFile.href='javascript:void(0)';
 	linkFile.onclick=function () {removeFile(this.id.replace("link","div")); return false;};
-	linkFile.innerHTML=get_lang("Remove");	
+	linkFile.innerHTML=get_lang("Remove");
 	//divFile.innerHTML += "&nbsp;&nbsp;";
 	divFile.appendChild(linkFile);
-	divFile.id = "divFile_"+id_border+"_"+countDivFiles;	
+	divFile.id = "divFile_"+id_border+"_"+countDivFiles;
 	divFiles.appendChild(divFile);
 
-	
+
 
 	return document.getElementById("inputFile_"+id_border+"_"+countDivFiles);
@@ -357,5 +357,5 @@
 
 function validateFileExtension(fileName, id, id_border){
-	
+
 	var error_flag  = false;
 
@@ -365,8 +365,8 @@
 			var file = fileName.substr(fileName.lastIndexOf('\\') + 1, fileName.length);
 			if ((fileName.indexOf(':\\') != 1) && (fileName.indexOf('\\\\') != 0)) // Is stored in partition or a network file?
-				error_flag = true;	
+				error_flag = true;
 		}
 		else // is Unix
-			var file = fileName.substr(fileName.lastIndexOf('/') + 1, fileName.length);						
+			var file = fileName.substr(fileName.lastIndexOf('/') + 1, fileName.length);
 	}
 	else  // is Firefox 3
@@ -382,5 +382,5 @@
 			break;
 		}
-			
+
 	}
 
@@ -399,9 +399,9 @@
 // Funcao usada para escrever mensagem
 // notimeout = True : mensagem nao apaga
-function write_msg(msg, notimeout){	
-	
+function write_msg(msg, notimeout){
+
 	if (setTimeout_write_msg)
 		clearTimeout(setTimeout_write_msg);
-	
+
 	var msg_div = Element('em_div_write_msg');
 	var old_divStatusBar = Element("divStatusBar");
@@ -413,5 +413,5 @@
 		old_divStatusBar.parentNode.insertBefore(msg_div,old_divStatusBar);
 	}
-	
+
 	if( document.getElementById('JabberMessenger'))
 		loadscript.adIcon();
@@ -420,5 +420,5 @@
 
 	old_divStatusBar.style.display = 'none';
-	msg_div.style.display = '';	
+	msg_div.style.display = '';
 	// Nao ponha var na frente!! jakjr
 	handle_write_msg = function(){
@@ -427,5 +427,5 @@
 				clean_msg();
 			else
-				write_msg(old_msg, true);			
+				write_msg(old_msg, true);
 		}
 		catch(e){}
@@ -443,5 +443,5 @@
 	if(msg_div)
 		msg_div.style.display = 'none';
-	old_divStatusBar.style.display = '';	
+	old_divStatusBar.style.display = '';
 }
 
@@ -507,5 +507,5 @@
 		return;
 	}
-		
+
 	var handler_emQuickSearch = function(data)
 	{
@@ -514,10 +514,10 @@
 			window_DropDownContacts.style.visibility = 'hidden';
 		}
-		
+
 		if ((!data.status) && (data.error == "many results")){
 			alert(get_lang('More than %1 results. Please, try to refine your search.',200));
 			return false;
 		}
-			
+
 		if (data.length > 0){
 			if ((field != 'null') && (ID != 'null'))
@@ -544,5 +544,5 @@
 		return true;
 	}
-	
+
 	if ((field != 'null') && (ID != 'null'))
 	{
@@ -564,10 +564,10 @@
 	else
 		var search_for = emailList;
-	
+
 	if (search_for.length < preferences.search_characters_number){
             alert(get_lang('Your search argument must be longer than %1 characters.', preferences.search_characters_number));
             return false;
 	}
-	
+
 	cExecute ("$this.ldap_functions.quicksearch&search_for="+search_for+"&field="+field+"&ID="+ID, handler_emQuickSearch);
 }
@@ -680,11 +680,12 @@
 	var n, strCode, strDecode = "";
 	for (n = 0; n < str.length; n++) {
-	    if (str.charAt(n) == "%") {
-	        strCode = str.charAt(n + 1) + str.charAt(n + 2);
-	        strDecode += String.fromCharCode(parseInt(strCode, 16));
-	        n += 2;
-	    } else {
-	        strDecode += str.charAt(n);
-	    }
+            strDecode += str.charAt(n);
+	    //if (str.charAt(n) == "%") {
+	    //    strCode = str.charAt(n + 1) + str.charAt(n + 2);
+	    //    strDecode += String.fromCharCode(parseInt(strCode, 16));
+	    //    n += 2;
+	    //} else {
+	    //    strDecode += str.charAt(n);
+	    //}
 	}
 	return strDecode;
@@ -713,8 +714,8 @@
 			var Lp=obj.createTextRange();
 		}
-		
+
 		Lp.setEndPoint("EndToStart",M);
 		var rb=Lp.text.length;
-		
+
 		if(rb > obj.value.length)
 		{
@@ -726,22 +727,22 @@
 
 function trim(inputString) {
-   if (typeof inputString != "string") 
+   if (typeof inputString != "string")
    	return inputString;
-      
+
    var retValue = inputString;
    var ch = retValue.substring(0, 1);
-   while (ch == " ") { 
+   while (ch == " ") {
 	  retValue = retValue.substring(1, retValue.length);
 	  ch = retValue.substring(0, 1);
    }
    ch = retValue.substring(retValue.length-1, retValue.length);
-   while (ch == " ") { 
+   while (ch == " ") {
 	  retValue = retValue.substring(0, retValue.length-1);
 	  ch = retValue.substring(retValue.length-1, retValue.length);
    }
-   while (retValue.indexOf("  ") != -1) { 
-	  retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); 
+   while (retValue.indexOf("  ") != -1) {
+	  retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length);
    }
-   return retValue; 
+   return retValue;
 }
 
@@ -922,5 +923,5 @@
 	var main_list = main.childNodes;
 	var len_main_list = main_list.length;
-	
+
 	if (select)
 	{
Index: /branches/2.2/expressoMail1_2/js/draw_api.js
===================================================================
--- /branches/2.2/expressoMail1_2/js/draw_api.js	(revision 3352)
+++ /branches/2.2/expressoMail1_2/js/draw_api.js	(revision 3369)
@@ -569,8 +569,8 @@
 	lnk_page.title = get_lang("First");
   	span_paging.innerHTML += "&nbsp;";
-  
+
   	if(current_page == lastPage + numPages)
-  		lastPage = current_page - 1;  
-  	else if((lastPage != 1 && lastPage == current_page) || current_page == total_pages)  
+  		lastPage = current_page - 1;
+  	else if((lastPage != 1 && lastPage == current_page) || current_page == total_pages)
   		lastPage = current_page - (numPages - 1);
   	else if(current_page == 1)
@@ -585,6 +585,6 @@
 
   	for(i = lastPage; i <= total_pages; i++) {
-  
-  		if(current_page == i || (i == total_pages && !hasMarked)) {	  
+
+  		if(current_page == i || (i == total_pages && !hasMarked)) {
   			lnk_page = document.createElement("SPAN");
   			span_paging.appendChild(lnk_page);
@@ -593,5 +593,5 @@
   			continue;
   		}
-  		else{	  
+  		else{
   			lnk_page = document.createElement("A");
   			span_paging.appendChild(lnk_page);
@@ -605,5 +605,5 @@
   		else if(lastPage == 1 || i != lastPage)
   			lnk_page.innerHTML = "&nbsp;"+i+"&nbsp;";
-  		span_paging.innerHTML += "&nbsp;"; 
+  		span_paging.innerHTML += "&nbsp;";
   	}
 
@@ -611,5 +611,5 @@
   		lnk_page = document.createElement("A");
   		msg_range_begin = ((total_pages*preferences.max_email_per_page)-(preferences.max_email_per_page-1));
-		msg_range_end = (total_pages*preferences.max_email_per_page);  
+		msg_range_end = (total_pages*preferences.max_email_per_page);
 		lnk_page.setAttribute("href", "javascript:current_page="+total_pages+";kill_current_box(); draw_paging("+num_msgs+"); proxy_mensagens.messages_list(get_current_folder(),"+msg_range_begin+","+msg_range_end+",'"+sort_box_type+"','"+search_box_type+"',"+sort_box_reverse+","+preferences.preview_msg_subject+","+preferences.preview_msg_tip+",function handler(data){draw_box(data, get_current_folder());});");
 	}
@@ -833,5 +833,5 @@
 							"TreeShow");
 	connector.loadAllScripts(scripts);
-	// Loading Quota View Folder Component (if exists...) 
+	// Loading Quota View Folder Component (if exists...)
 	if(Element("table_quota"))
 		connector.loadScript("InfoQuota");
@@ -1293,5 +1293,5 @@
 	td.innerHTML = _name.bold() + ', ' + info_msg.smalldate;
 	if (info_msg.attachments && info_msg.attachments.length > 0)
-		td.innerHTML += "&nbsp<img style='cursor:pointer' onclick='javascript:Element(\"option_hide_more_"+ID+"\").onclick()' src ='templates/"+template+"/images/clip.gif' title='"+info_msg.attachments.names+"'>";
+		td.innerHTML += "&nbsp<img style='cursor:pointer' onclick='javascript:Element(\"option_hide_more_"+ID+"\").onclick()' src ='templates/"+template+"/images/clip.gif' title='"+info_msg.attachments[0].name+"'>";
 
 	if (typeof(info_msg.signature) == 'string')
@@ -2005,5 +2005,5 @@
 		}catch(e){
 		}
-	} 
+	}
 	//////////////////////////////////////////////////////////////////////////////////////////////////////
 	//Make the thumbs of the message.
