diff --git a/src/core/dataprotocol.cpp b/src/core/dataprotocol.cpp --- a/src/core/dataprotocol.cpp +++ b/src/core/dataprotocol.cpp @@ -16,9 +16,6 @@ * * ***************************************************************************/ -// TODO: remove me -#undef QT_NO_CAST_FROM_ASCII - #include "dataprotocol_p.h" #include "global.h" @@ -109,19 +106,19 @@ { int oldpos = pos; pos = find(buf, oldpos, c1); - return buf.mid(oldpos, pos - oldpos); + return QString::fromLatin1(buf.mid(oldpos, pos - oldpos)); } /** ignores all whitespaces * @param buf buffer to operate on * @param pos position to shift to first non-whitespace character * Upon return @p pos will either point to the first non-whitespace * character or to the end of the buffer. */ -static inline void ignoreWS(const QString &buf, int &pos) +static inline void ignoreWS(const QByteArray &buf, int &pos) { int size = buf.length(); - while (pos < size && buf[pos].isSpace()) { + while (pos < size && (buf[pos] == ' ' || buf[pos] == '\t')) { ++pos; } } @@ -134,16 +131,16 @@ * @return the extracted string. @p pos will be updated to point to the * character following the trailing quote. */ -static QString parseQuotedString(const QString &buf, int &pos) +static QString parseQuotedString(const QByteArray &buf, int &pos) { int size = buf.length(); QString res; res.reserve(size); // can't be larger than buf pos++; // jump over leading quote bool escaped = false; // if true means next character is literal bool parsing = true; // true as long as end quote not found while (parsing && pos < size) { - const QChar ch = buf[pos++]; + const QChar ch = QLatin1Char(buf[pos++]); if (escaped) { res += ch; escaped = false; @@ -195,7 +192,7 @@ return header_info; } // jump over delimiter token and return if data reached - if (raw_url[header_info.data_offset++] == QLatin1Char(',')) { + if (raw_url[header_info.data_offset++] == ',') { return header_info; } @@ -205,7 +202,7 @@ // read attribute const QString attribute = extract(raw_url, header_info.data_offset, '=').trimmed(); if (header_info.data_offset >= raw_url_len - || raw_url[header_info.data_offset] != QLatin1Char('=')) { + || raw_url[header_info.data_offset] != '=') { // no assignment, must be base64 option if (attribute == QLatin1String("base64")) { header_info.is_base64 = true; @@ -220,7 +217,7 @@ } QString value; - if (raw_url[header_info.data_offset] == QLatin1Char('"')) { + if (raw_url[header_info.data_offset] == '"') { value = parseQuotedString(raw_url, header_info.data_offset); ignoreWS(raw_url, header_info.data_offset); } else { @@ -232,7 +229,7 @@ }/*end if*/ if (header_info.data_offset < raw_url_len - && raw_url[header_info.data_offset] == QLatin1Char(',')) { + && raw_url[header_info.data_offset] == ',') { data_begin_reached = true; } header_info.data_offset++; // jump over separator token