forked from openkylin/ukui-search
Determine whether the OpenXML file is encrypted.
This commit is contained in:
parent
52f8bb042f
commit
b3c2ed7fec
|
@ -892,6 +892,25 @@ QIcon FileUtils::iconFromTheme(const QString &name, const QIcon &iconDefault)
|
||||||
return QIcon::fromTheme(name, iconDefault);
|
return QIcon::fromTheme(name, iconDefault);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool FileUtils::isOpenXMLFileEncrypted(QString &path)
|
||||||
|
{
|
||||||
|
QFile file(path);
|
||||||
|
file.open(QIODevice::ReadOnly|QIODevice::Text);
|
||||||
|
QByteArray encrypt = file.read(4);
|
||||||
|
file.close();
|
||||||
|
if (encrypt.length() < 4) {
|
||||||
|
qDebug() << "Reading file error!" << path;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
//比较前四位是否为对应值来判断OpenXML类型文件是否加密
|
||||||
|
if (encrypt[0] == 0x50 && encrypt[1] == 0x4b && encrypt[2] == 0x03 && encrypt[3] == 0x04) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
qDebug() << "Encrypt!" << path;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QString FileUtils::getHtmlText(const QString &text, const QString &keyword)
|
QString FileUtils::getHtmlText(const QString &text, const QString &keyword)
|
||||||
{
|
{
|
||||||
QString htmlString;
|
QString htmlString;
|
||||||
|
|
|
@ -96,6 +96,7 @@ public:
|
||||||
static QString escapeHtml(const QString & str);
|
static QString escapeHtml(const QString & str);
|
||||||
static QString chineseSubString(const std::string &myStr,int start,int length);
|
static QString chineseSubString(const std::string &myStr,int start,int length);
|
||||||
static QIcon iconFromTheme(const QString& name, const QIcon &iconDefault);
|
static QIcon iconFromTheme(const QString& name, const QIcon &iconDefault);
|
||||||
|
static bool isOpenXMLFileEncrypted(QString &path);
|
||||||
static size_t _max_index_count;
|
static size_t _max_index_count;
|
||||||
static size_t _current_index_count; //this one has been Abandoned,do not use it.
|
static size_t _current_index_count; //this one has been Abandoned,do not use it.
|
||||||
static unsigned short _index_status;
|
static unsigned short _index_status;
|
||||||
|
|
|
@ -4884,7 +4884,7 @@ bool KBinaryParser::read8DocText(FILE *pFile, const ppsInfoType *pPPS,
|
||||||
ulBeginTextInfo = ulGetLong(0x1a2, aucHeader); /* fcClx */
|
ulBeginTextInfo = ulGetLong(0x1a2, aucHeader); /* fcClx */
|
||||||
tTextInfoLen = (size_t)ulGetLong(0x1a6, aucHeader); /* lcbClx */
|
tTextInfoLen = (size_t)ulGetLong(0x1a6, aucHeader); /* lcbClx */
|
||||||
ulEncryptInfo = ulGetLong(0x0a, aucHeader);
|
ulEncryptInfo = ulGetLong(0x0a, aucHeader);
|
||||||
if(ulEncryptInfo & 0x0100) {
|
if(ulEncryptInfo & BIT(8)) {
|
||||||
qDebug() << "Encrypt file:" << m_strFileName << (size_t)ulEncryptInfo;
|
qDebug() << "Encrypt file:" << m_strFileName << (size_t)ulEncryptInfo;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue