From 26d3681ed7bf2b6681a594511291e39a840dc8af Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Tue, 10 Feb 2015 10:59:15 +0100 Subject: Bluez5: Fix plain text handover of xml from sdpscanner The plain text option was never triggered as the raw data processing always considered \0 as part of the string. Subsequently the string was always evaluated to be non-printable and the hex based handover was triggered. Fortunately the hex based handover worked without trouble. In addition the plain value was not properly escaped to be valid XML. Change-Id: I537a94ef4705c7eeab143b3053affc6abbd548cc Reviewed-by: Kai Koehne --- src/tools/sdpscanner/main.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'src/tools/sdpscanner') diff --git a/src/tools/sdpscanner/main.cpp b/src/tools/sdpscanner/main.cpp index 5cf4ceb0..cb1bdd15 100644 --- a/src/tools/sdpscanner/main.cpp +++ b/src/tools/sdpscanner/main.cpp @@ -141,9 +141,13 @@ static void parseAttributeValues(sdp_data_t *data, int indentation, QByteArray & QByteArray text = QByteArray::fromRawData(data->val.str, data->unitSize); bool hasNonPrintableChar = false; - for (int i = 0; i < text.count() && !hasNonPrintableChar; i++) { - if (!isprint(text[i])) { + for (int i = 0; i < text.count(); i++) { + if (text[i] == '\0') { + text.resize(i); // cut trailing content + break; + } else if (!isprint(text[i])) { hasNonPrintableChar = true; + text.resize(text.indexOf('\0')); // cut trailing content break; } } @@ -152,10 +156,10 @@ static void parseAttributeValues(sdp_data_t *data, int indentation, QByteArray & xmlOutput.append("encoding=\"hex\" value=\""); xmlOutput.append(text.toHex()); } else { - text.replace('&', "&"); - text.replace('<', "<"); - text.replace('>', ">"); - text.replace('"', """); + text.replace('&', "&"); + text.replace('<', "<"); + text.replace('>', ">"); + text.replace('"', """); xmlOutput.append("value=\""); xmlOutput.append(text); -- cgit v1.2.3