Index: /trunk/zoo-kernel/service_internal.c
===================================================================
--- /trunk/zoo-kernel/service_internal.c	(revision 93)
+++ /trunk/zoo-kernel/service_internal.c	(revision 94)
@@ -1400,5 +1400,6 @@
 	  isSized=false;
 	}
-	xmlAddChild(nc3,xmlNewText(BAD_CAST base64((const unsigned char*)toto->value,atoi(rs->value))));
+
+	xmlAddChild(nc3,xmlNewText(BAD_CAST base64(toto->value, atoi(rs->value))));
 	if(!isSized){
 	  freeMap(&rs);
@@ -1762,4 +1763,5 @@
 
   b64 = BIO_new(BIO_f_base64());
+  BIO_set_flags(b64, BIO_FLAGS_BASE64_NO_NL);
   bmem = BIO_new(BIO_s_mem());
   b64 = BIO_push(b64, bmem);
@@ -1768,5 +1770,5 @@
   BIO_get_mem_ptr(b64, &bptr);
 
-  char *buff = (char *)malloc(bptr->length);
+  char *buff = (char *)malloc((bptr->length)*sizeof(char));
   memcpy(buff, bptr->data, bptr->length-1);
   buff[bptr->length-1] = 0;
@@ -1782,14 +1784,15 @@
 
   char *buffer = (char *)malloc(length);
-  memset(buffer, 0, length);
-
-  b64 = BIO_new(BIO_f_base64());
-  bmem = BIO_new_mem_buf(input, length);
-  bmem = BIO_push(b64, bmem);
-
-  *red=BIO_read(bmem, buffer, length);
-
-  BIO_free_all(bmem);
-
+  if(buffer){
+    memset(buffer, 0, length);
+    b64 = BIO_new(BIO_f_base64());
+    if(b64){
+      bmem = BIO_new_mem_buf(input,length);
+      bmem = BIO_push(b64, bmem);
+      *red=BIO_read(bmem, buffer, length);
+      buffer[length-1]=0;
+      BIO_free_all(bmem);
+    }
+  }
   return buffer;
 }
@@ -1802,8 +1805,9 @@
       tmp=getMap(cursor->content,"value");
       addToMap(cursor->content,"base64_value",tmp->value);
+      int size=0;
       char *s=strdup(tmp->value);
       free(tmp->value);
-      int size=0;
       tmp->value=base64d(s,strlen(s),&size);
+      free(s);
       char sizes[1024];
       sprintf(sizes,"%d",size);
Index: /trunk/zoo-kernel/zoo_service_loader.c
===================================================================
--- /trunk/zoo-kernel/zoo_service_loader.c	(revision 93)
+++ /trunk/zoo-kernel/zoo_service_loader.c	(revision 94)
@@ -1343,16 +1343,48 @@
 		}
 	      }
-	      xmlChar* mv=xmlNodeListGetString(doc,cur4->xmlChildrenNode,1);
-	      if(mv==NULL){
-		xmlDocPtr doc1=xmlNewDoc(BAD_CAST "1.0");
-		int buffersize;
-		xmlDocSetRootElement(doc1,cur4->xmlChildrenNode);
-		xmlDocDumpFormatMemoryEnc(doc1, &mv, &buffersize, "utf-8", 1);
-		char size[1024];
-		sprintf(size,"%d",buffersize);
-		addToMap(tmpmaps->content,"size",size);
+	      map* test=getMap(tmpmaps->content,"encoding");
+	      if(test==NULL || strcasecmp(test->value,"base64")!=0){
+		xmlChar* mv=xmlNodeListGetString(doc,cur4->xmlChildrenNode,1);
+		if(mv==NULL){
+		  xmlDocPtr doc1=xmlNewDoc(BAD_CAST "1.0");
+		  int buffersize;
+		  xmlDocSetRootElement(doc1,cur4->xmlChildrenNode);
+		  xmlDocDumpFormatMemoryEnc(doc1, &mv, &buffersize, "utf-8", 1);
+		  char size[1024];
+		  sprintf(size,"%d",buffersize);
+		  addToMap(tmpmaps->content,"size",size);
+		}
+		addToMap(tmpmaps->content,"value",(char*)mv);
+		xmlFree(mv);
+	      }else{
+		xmlSubstituteEntitiesDefault(1);
+		xmlChar* tmp=xmlNodeListGetString(doc,cur4->xmlChildrenNode,0);
+		addToMap(tmpmaps->content,"value",(char*)tmp);
+		map* tmpv=getMap(tmpmaps->content,"value");
+		char *res=NULL;
+		char *curs=tmpv->value;
+		int i=0;
+		for(int i=0;i<=strlen(tmpv->value)/64;i++) {
+		  if(res==NULL)
+		    res=(char*)malloc(67*sizeof(char));
+		  else
+		    res=(char*)realloc(res,(((i+1)*65)+i)*sizeof(char));
+		  int csize=i*65;
+		  strncpy(res + csize,curs,64);
+		  if(i==xmlStrlen(tmp)/64)
+		    strcat(res,"\n\0");
+		  else{
+		    strncpy(res + (((i+1)*64)+i),"\n\0",2);
+		    curs+=64;
+		  }
+		}
+		free(tmpv->value);
+		tmpv->value=strdup(res);
+		for(int j=0;j<strlen(tmpv->value);j++)
+		  if(tmpv->value[j]==' ')
+		    tmpv->value[j]='+';
+		free(res);
+		xmlFree(tmp);
 	      }
-	      addToMap(tmpmaps->content,"value",(char*)mv);
-	      xmlFree(mv);
 	      cur4=cur4->next;
 	    }
@@ -1731,5 +1763,5 @@
   int eres=SERVICE_STARTED;
   int cpid=getpid();
-  
+
   maps *_tmpMaps=(maps*)malloc(MAPS_SIZE);
   _tmpMaps->name=strdup("lenv");
@@ -1836,5 +1868,4 @@
       errorException(m, _("Unable to run the child process properly"), "InternalError");
     }
-      	
   }
 
