diff options
author | Alex Blasche <alexander.blasche@theqtcompany.com> | 2015-02-10 10:59:15 +0100 |
---|---|---|
committer | Sergio Ahumada <sahumada@texla.cl> | 2015-02-12 08:05:33 +0000 |
commit | 26d3681ed7bf2b6681a594511291e39a840dc8af (patch) | |
tree | 2e38f7300f9665ab248bded4bbfc410aa1cd0400 /src/tools | |
parent | 0c1409fb517e98200cdc4d4790aa03119f14cb9f (diff) |
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 <kai.koehne@theqtcompany.com>
Diffstat (limited to 'src/tools')
-rw-r--r-- | src/tools/sdpscanner/main.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
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); |