upnpsoap: Work around some bad SearchCriteria

The Control4 app apparently sends us badly-formatted SearchCriteria,
where they don't quote the upnp:class value.  So we'll add it in for them
if we detect that situation.

Fixes: SF Patches #173 (DLNA search query not as minidlna expects)
This commit is contained in:
Justin Maggard 2018-01-18 17:35:02 -08:00
parent f2294ebea8
commit fa20ca8526

View File

@ -1035,6 +1035,7 @@ callback(void *args, int argc, char **argv, char **azColName)
sql_get_int_field(db, "SELECT WATCH_COUNT from BOOKMARKS where ID = '%s'", detailID)); sql_get_int_field(db, "SELECT WATCH_COUNT from BOOKMARKS where ID = '%s'", detailID));
} }
} }
free(alt_title);
if( artist ) { if( artist ) {
if( (*mime == 'v') && (passed_args->filter & FILTER_UPNP_ACTOR) ) { if( (*mime == 'v') && (passed_args->filter & FILTER_UPNP_ACTOR) ) {
ret = strcatf(str, "<upnp:actor>%s</upnp:actor>", artist); ret = strcatf(str, "<upnp:actor>%s</upnp:actor>", artist);
@ -1172,7 +1173,6 @@ callback(void *args, int argc, char **argv, char **azColName)
"</sec:CaptionInfoEx>", "</sec:CaptionInfoEx>",
lan_addr[passed_args->iface].str, runtime_vars.port, detailID); lan_addr[passed_args->iface].str, runtime_vars.port, detailID);
} }
free(alt_title);
break; break;
} }
} }
@ -1522,7 +1522,7 @@ parse_search_criteria(const char *str, char *sep)
{ {
struct string_s criteria; struct string_s criteria;
int len; int len;
int literal = 0, like = 0; int literal = 0, like = 0, class = 0;
const char *s; const char *s;
if (!str) if (!str)
@ -1572,13 +1572,17 @@ parse_search_criteria(const char *str, char *sep)
} }
break; break;
case 'o': case 'o':
if (strncmp(s, "object.", 7) == 0) if (class)
s += 7;
else if (strncmp(s, "object\"", 7) == 0 ||
strncmp(s, "object"", 12) == 0)
{ {
s += 6; class = 0;
continue; if (strncmp(s, "object.", 7) == 0)
s += 7;
else if (strncmp(s, "object\"", 7) == 0 ||
strncmp(s, "object"", 12) == 0)
{
s += 6;
continue;
}
} }
default: default:
charcat(&criteria, *s); charcat(&criteria, *s);
@ -1720,11 +1724,29 @@ parse_search_criteria(const char *str, char *sep)
else else
charcat(&criteria, *s); charcat(&criteria, *s);
break; break;
case 'o':
if (class)
{
if (strncmp(s, "object.", 7) == 0)
{
s += 7;
charcat(&criteria, '"');
while (*s && !isspace(*s))
{
charcat(&criteria, *s);
s++;
}
charcat(&criteria, '"');
}
class = 0;
continue;
}
case 'u': case 'u':
if (strncmp(s, "upnp:class", 10) == 0) if (strncmp(s, "upnp:class", 10) == 0)
{ {
strcatf(&criteria, "o.CLASS"); strcatf(&criteria, "o.CLASS");
s += 10; s += 10;
class = 1;
continue; continue;
} }
else if (strncmp(s, "upnp:actor", 10) == 0) else if (strncmp(s, "upnp:actor", 10) == 0)