mirror of
https://github.com/owntone/owntone-server.git
synced 2025-04-19 02:15:18 -04:00
Fix garbage characters on entity-encoding dmap strings, also fix browse results
This commit is contained in:
parent
72d2d7c5c8
commit
ea71a2b410
@ -353,12 +353,20 @@ DAAP_ITEMS *daap_lookup_tag(char *tag) {
|
||||
/**
|
||||
* xml entity encoding, stupid style
|
||||
*/
|
||||
char *daap_xml_entity_encode(char *original) {
|
||||
char *daap_xml_entity_encode(char *original, int len) {
|
||||
char *new;
|
||||
char *s, *d;
|
||||
int destsize;
|
||||
int truelen;
|
||||
|
||||
destsize = 6*strlen(original)+1;
|
||||
/* this is about stupid */
|
||||
if(len) {
|
||||
truelen=len;
|
||||
} else {
|
||||
truelen=strlen(original);
|
||||
}
|
||||
|
||||
destsize = 6*truelen+1;
|
||||
new=(char *)malloc(destsize);
|
||||
if(!new) return NULL;
|
||||
|
||||
@ -367,7 +375,7 @@ char *daap_xml_entity_encode(char *original) {
|
||||
s=original;
|
||||
d=new;
|
||||
|
||||
while(*s) {
|
||||
while(s < (original+truelen)) {
|
||||
switch(*s) {
|
||||
case '>':
|
||||
strcat(d,">");
|
||||
@ -420,7 +428,6 @@ int daap_serialize_xml(DAAP_BLOCK *root, int fd) {
|
||||
|
||||
pitem=daap_lookup_tag(root->tag);
|
||||
r_fdprintf(fd,"<%s>",pitem->description);
|
||||
if(pitem->type != 0x0c) { /* container */
|
||||
switch(pitem->type) {
|
||||
case 0x01: /* byte */
|
||||
r_fdprintf(fd,"%d",*((char *)data));
|
||||
@ -454,7 +461,8 @@ int daap_serialize_xml(DAAP_BLOCK *root, int fd) {
|
||||
r_fdprintf(fd,"%ll",ivalue);
|
||||
break;
|
||||
case 0x09: /* string */
|
||||
encoded_string=daap_xml_entity_encode(data);
|
||||
case 0x0C: /* container, but mlit is a string in browse */
|
||||
encoded_string=daap_xml_entity_encode(data,root->size);
|
||||
r_fdprintf(fd,"%s",encoded_string);
|
||||
free(encoded_string);
|
||||
break;
|
||||
@ -467,9 +475,10 @@ int daap_serialize_xml(DAAP_BLOCK *root, int fd) {
|
||||
pitem->type, pitem->description);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
|
||||
if(root->children)
|
||||
daap_serialize_xml(root->children,fd);
|
||||
}
|
||||
|
||||
r_fdprintf(fd,"</%s>",pitem->description);
|
||||
root=root->next;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user