Skip to content

Commit

Permalink
Data Browser: avoid showing BLOBs containing unprintable characters a…
Browse files Browse the repository at this point in the history
…s text

See comments in sqlitebrowser#1201
  • Loading branch information
mgrojo committed Dec 20, 2020
1 parent e0b40ad commit 5e0c56a
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/Data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,16 @@ bool isTextOnly(QByteArray data, const QString& encoding, bool quickTest)
} else {
// Convert to Unicode if necessary
data = decodeString(data, encoding);
QString text (data);
bool isPrintable = true;
for(QChar character : text) {
if(!character.isPrint()) {
isPrintable = false;
break;
}
}
// Perform check
return QString(data).toUtf8() == data;
return isPrintable && text.toUtf8() == data;
}
}

Expand Down

0 comments on commit 5e0c56a

Please sign in to comment.