diff --git a/lib/raop.c b/lib/raop.c
index 4175d05..dbc5eca 100644
--- a/lib/raop.c
+++ b/lib/raop.c
@@ -310,7 +310,8 @@ conn_request(void *ptr, http_request_t *request, http_response_t **response) {
char * plist_xml;
uint32_t plist_len;
plist_to_xml(req_root_node, &plist_xml, &plist_len);
- logger_log(conn->raop->logger, LOGGER_DEBUG, "%s", plist_xml);
+ plist_xml = utils_strip_data_from_plist_xml(plist_xml);
+ logger_log(conn->raop->logger, LOGGER_DEBUG, "%s", plist_xml);
free(plist_xml);
plist_free(req_root_node);
} else if (data_is_text) {
@@ -444,9 +445,10 @@ conn_request(void *ptr, http_request_t *request, http_response_t **response) {
char * plist_xml;
uint32_t plist_len;
plist_to_xml(res_root_node, &plist_xml, &plist_len);
- plist_free(res_root_node);
+ plist_xml = utils_strip_data_from_plist_xml(plist_xml);
logger_log(conn->raop->logger, LOGGER_DEBUG, "%s", plist_xml);
free(plist_xml);
+ plist_free(res_root_node);
} else if (data_is_text) {
char *data_str = utils_data_to_text((char*) response_data, response_datalen);
logger_log(conn->raop->logger, LOGGER_DEBUG, "%s", data_str);
diff --git a/lib/utils.c b/lib/utils.c
index 8f82186..ac2eee8 100644
--- a/lib/utils.c
+++ b/lib/utils.c
@@ -283,6 +283,64 @@ int utils_ipaddress_to_string(int addresslen, const unsigned char *address, unsi
return ret;
}
+char *utils_strip_data_from_plist_xml(char *plist_xml) {
+ /* returns pointer to *plist_xml unchanged if no data needs to be stripped out.
+ * otherwise frees plist_xml and returns pointer to newly-allocated stripped text char *xml
+ * WHICH (like plist_xml) MUST BE FREED AFTER USE*/
+ assert(plist_xml);
+ int len = (int) strlen(plist_xml);
+ char *last = plist_xml + len * sizeof(char); // position of null termination of plist_xml
+
+ char *eol;
+ char *xml;
+ int nchars;
+ char line[81];
+ int count;
+ char *begin = strstr(plist_xml, "");
+ char *end;
+
+ if (!begin) {
+ /* there are no data lines, nothing to do */
+ return plist_xml;
+ } else {
+ xml = (char *) calloc((len + 1), sizeof(char));
+ }
+
+ char *ptr1 = plist_xml;
+ char *ptr2 = xml;
+ do {
+ eol = strchr(begin,'\n');
+ nchars = eol + 1 - ptr1;
+ memcpy(ptr2, ptr1, nchars);
+ ptr2 += nchars;
+ ptr1 += nchars;
+ end = strstr(ptr1, "");
+ assert(end);
+ count = 0;
+ do {
+ ptr1 = eol + 1;
+ eol = strchr(ptr1, '\n');
+ count++;
+ } while (eol < end);
+ count--; // last '\n' counted ends the first non-data line (contains "")
+ if (count) {
+ snprintf(line, sizeof(line), " ... (%d line%s of base64-encoded data not shown, 64 chars/line) ...\n",
+ count, (count == 1 ? "" : "s"));
+ }
+ memcpy(ptr2, line, strlen(line));
+ ptr2 += strlen(line);
+ begin = strstr(ptr1, "");
+ if (begin == NULL) {
+ nchars = (int) (last + 1 - ptr1);
+ memcpy(ptr2, ptr1, nchars); //includes the null terminator
+ break;
+ }
+ } while (ptr1 <= last);
+
+ free (plist_xml);
+ return xml;
+}
+
const char *gmt_time_string() {
static char date_buf[64];
memset(date_buf, 0, 64);
diff --git a/lib/utils.h b/lib/utils.h
index 82df1f5..7eef153 100644
--- a/lib/utils.h
+++ b/lib/utils.h
@@ -33,4 +33,5 @@ void ntp_timestamp_to_seconds(uint64_t ntp_timestamp, char *timestamp, size_t ma
const char *gmt_time_string();
int utils_ipaddress_to_string(int addresslen, const unsigned char *address,
unsigned int zone_id, char *string, int len);
+char *utils_strip_data_from_plist_xml(char * plist_xml);
#endif