Index: /trunk/expressoMail1_2/inc/class.imap_functions.inc.php
===================================================================
--- /trunk/expressoMail1_2/inc/class.imap_functions.inc.php	(revision 349)
+++ /trunk/expressoMail1_2/inc/class.imap_functions.inc.php	(revision 372)
@@ -2110,23 +2110,35 @@
 				$tmp1 = explode("##",$tmp);
 				$name_box = $tmp1[0];
-				$criteria = explode("<=>",rawurldecode($tmp1[1]));				
-				$criteria[1] = $this->remove_accents($criteria[1]);
+				unset($filter);
+				foreach($tmp1 as $index => $criteria)
+				{
+					if ($index != 0 && strlen($criteria) != 0)
+					{
+						$filter_array = explode("<=>",rawurldecode($criteria));
+						$filter .= " ".$filter_array[0];
+						$filter .= '"'.$filter_array[1].'"';
+					}
+				}		
+				$name_box = mb_convert_encoding(utf8_decode($name_box), "UTF7-IMAP", "ISO_8859-1" ); 
+				$filter = $this->remove_accents($filter);
 				
 				if(!is_resource($mbox_stream))
-					$mbox_stream = $this->open_mbox();
+					$mbox_stream = $this->open_mbox($name_box);
 				else
 					imap_reopen($mbox_stream, "{".$this->imap_server.":".$this->imap_port.$this->imap_options."}".$name_box);
+			
+				if (preg_match("/^.?\bALL\b/", $filter)){ // Quick Search, note: this ALL isn't the same ALL from imap_search 	
 				
-				if($criteria[0] == "ALL ") {					
 					$all_criterias = array ("TO","SUBJECT","FROM","CC");
 					foreach($all_criterias as $criteria_fixed)
 					{
-						$filter = $criteria_fixed . ' "' . $criteria[1] . '"';
-						$search_criteria = imap_search($mbox_stream, $filter, SE_UID);
+						$_filter = $criteria_fixed . substr($filter,4);
+					
+						$search_criteria = imap_search($mbox_stream, $_filter, SE_UID);
 						
 						if($search_criteria && count($search_criteria) < 50)
 						{
 							foreach($search_criteria as $new_search){
-								$m_token = trim("##".$name_box . "--" . $this->get_msg($new_search,$name_box,$mbox_stream) . "--".$new_search."##"."\n");
+								$m_token = trim("##".mb_convert_encoding( $name_box, "ISO_8859-1", "UTF7-IMAP" ) . "--" . $this->get_msg($new_search,$name_box,$mbox_stream) . "--".$new_search."##"."\n");
 								if(!@strstr($retorno,$m_token))
 									$retorno .= $m_token;
@@ -2138,11 +2150,9 @@
 				}
 				else {
-					$filter = $criteria[0] . '"' . $criteria[1] . '"';
 					$search_criteria = imap_search($mbox_stream, $filter, SE_UID);
-											
-					if($search_criteria) {
-						foreach($search_criteria as $new_search){
-							$retorno .= trim("##".$name_box . "--" . $this->get_msg($new_search,$name_box,$mbox_stream) . "--".$new_search."##"."\n");
-						}
+					if( is_array( $search_criteria) )
+					{
+						foreach($search_criteria as $new_search)
+							$retorno .= trim("##".mb_convert_encoding( $name_box, "ISO_8859-1", "UTF7-IMAP" ) . "--" . $this->get_msg($new_search,$name_box,$mbox_stream) . "--" . $new_search."##"."\n");
 					}
 				}
Index: /trunk/expressoMail1_2/js/search.js
===================================================================
--- /trunk/expressoMail1_2/js/search.js	(revision 320)
+++ /trunk/expressoMail1_2/js/search.js	(revision 372)
@@ -527,24 +527,23 @@
 			// Verifica se os campos estão preenchidos;
 			if(trim(Element("txt_ass").value) != ""){
-				fields += "SUBJECT " +  "<=>" +url_encode(Element("txt_ass").value) + " ";
+				fields += "SUBJECT " +  "<=>" +url_encode(Element("txt_ass").value) + "##";
 			}
 			if(trim(Element("txt_body").value) != ""){
-				fields += "BODY " + "<=>" + url_encode(Element("txt_body").value) + " ";
+				fields += "BODY " + "<=>" + url_encode(Element("txt_body").value) + "##";
 			}
 			if(trim(Element("txt_de").value) != ""){
-				fields += "FROM " + "<=>" + url_encode(Element("txt_de").value) + " ";
+				fields += "FROM " + "<=>" + url_encode(Element("txt_de").value) + "##";
 			}
 			if(trim(Element("txt_para").value) != ""){
-				fields += "TO " + "<=>" + url_encode(Element("txt_para").value) + " ";
+				fields += "TO " + "<=>" + url_encode(Element("txt_para").value) + "##";
 			}
 			if(trim(Element("txt_cc").value) != ""){
-				fields += "CC " + "<=>" + url_encode(Element("txt_cc").value) + " ";
+				fields += "CC " + "<=>" + url_encode(Element("txt_cc").value) + "##";
 			}
 			if(value) {
-				fields = "##ALL " +  "<=>" +url_encode(value) + " ";
-			}
-
-		fields += "##";
-		if(fields == "####"){
+				fields = "##ALL " +  "<=>" +url_encode(value) + "##";
+			}
+
+		if(fields == "##"){
 			alert(get_lang("Define some search parameters!"));
 			return false;
