Commit a100e721 authored by Volker Krause's avatar Volker Krause
Browse files

The isspace/isctrl/etc functions require unsigned char as input

Using signed char is documented to be undefined behavior.
parent 421759f7
Pipeline #71558 passed with stage
in 9 minutes and 56 seconds
...@@ -26,7 +26,7 @@ Q_DECLARE_METATYPE(KItinerary::Internal::OwnedPtr<KItinerary::HtmlDocument>) ...@@ -26,7 +26,7 @@ Q_DECLARE_METATYPE(KItinerary::Internal::OwnedPtr<KItinerary::HtmlDocument>)
static bool contentStartsWith(const QByteArray &data, char s) static bool contentStartsWith(const QByteArray &data, char s)
{ {
for (const auto c : data) { for (unsigned char c : data) {
if (std::isspace(c)) { if (std::isspace(c)) {
continue; continue;
} }
...@@ -91,7 +91,7 @@ static QByteArray fixupJson(const QByteArray &data) ...@@ -91,7 +91,7 @@ static QByteArray fixupJson(const QByteArray &data)
for (int idx = output.indexOf("\",\n"); idx > 0 && idx + 3 < output.size(); idx = output.indexOf("\",\n", idx)) { for (int idx = output.indexOf("\",\n"); idx > 0 && idx + 3 < output.size(); idx = output.indexOf("\",\n", idx)) {
const auto comma = idx + 1; const auto comma = idx + 1;
idx += 3; idx += 3;
while (idx < output.size() && std::isspace(output[idx])) { while (idx < output.size() && std::isspace(static_cast<unsigned char>(output[idx]))) {
++idx; ++idx;
} }
if (idx < output.size() && output[idx] == '}') { if (idx < output.size() && output[idx] == '}') {
......
...@@ -32,7 +32,7 @@ using namespace KItinerary; ...@@ -32,7 +32,7 @@ using namespace KItinerary;
static bool contentStartsWith(const QByteArray &data, const char *str) static bool contentStartsWith(const QByteArray &data, const char *str)
{ {
auto it = data.begin(); auto it = data.begin();
while (it != data.end() && std::isspace(*it)) { while (it != data.end() && std::isspace(static_cast<unsigned char>(*it))) {
++it; ++it;
} }
......
...@@ -16,7 +16,7 @@ using namespace KItinerary; ...@@ -16,7 +16,7 @@ using namespace KItinerary;
static bool contentStartsWith(const QByteArray &data, char s) static bool contentStartsWith(const QByteArray &data, char s)
{ {
for (const auto c : data) { for (unsigned char c : data) {
if (std::isspace(c)) { if (std::isspace(c)) {
continue; continue;
} }
......
...@@ -18,7 +18,7 @@ using namespace KItinerary; ...@@ -18,7 +18,7 @@ using namespace KItinerary;
bool TextDocumentProcessor::canHandleData(const QByteArray &encodedData, QStringView fileName) const bool TextDocumentProcessor::canHandleData(const QByteArray &encodedData, QStringView fileName) const
{ {
return std::none_of(encodedData.begin(), encodedData.end(), [](auto c) { return std::iscntrl(c) && !std::isspace(c); }) return std::none_of(encodedData.begin(), encodedData.end(), [](unsigned char c) { return std::iscntrl(c) && !std::isspace(c); })
|| fileName.endsWith(QLatin1String(".txt"), Qt::CaseInsensitive); || fileName.endsWith(QLatin1String(".txt"), Qt::CaseInsensitive);
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment