Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qdecompresshelper_p.h
Go to the documentation of this file.
1
// Copyright (C) 2020 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
// Qt-Security score:significant reason:default
4
5
#
ifndef
DECOMPRESS_HELPER_P_H
6
#
define
DECOMPRESS_HELPER_P_H
7
8
//
9
// W A R N I N G
10
// -------------
11
//
12
// This file is not part of the Qt API. It exists for the convenience
13
// of the Network Access API. This header file may change from
14
// version to version without notice, or even be removed.
15
//
16
// We mean it.
17
//
18
19
#
include
<
QtNetwork
/
qtnetworkexports
.
h
>
20
#
include
<
QtNetwork
/
private
/
qbytedatabuffer_p
.
h
>
21
22
#
include
<
memory
>
23
24
QT_BEGIN_NAMESPACE
25
26
class
QIODevice;
27
class
QDecompressHelper
28
{
29
public
:
30
enum
ContentEncoding
{
31
None
,
32
Deflate
,
33
GZip
,
34
Brotli
,
35
Zstandard
,
36
};
37
38
QDecompressHelper
() =
default
;
39
Q_NETWORK_EXPORT
~
QDecompressHelper
();
40
41
Q_NETWORK_EXPORT
bool
setEncoding
(QByteArrayView contentEncoding);
42
43
Q_NETWORK_EXPORT
bool
isCountingBytes
()
const
;
44
Q_NETWORK_EXPORT
void
setCountingBytesEnabled
(
bool
shouldCount);
45
46
Q_NETWORK_EXPORT qint64
uncompressedSize
()
const
;
47
48
Q_NETWORK_EXPORT
bool
hasData
()
const
;
49
Q_NETWORK_EXPORT
void
feed
(
const
QByteArray &data);
50
Q_NETWORK_EXPORT
void
feed
(QByteArray &&data);
51
Q_NETWORK_EXPORT
void
feed
(
const
QByteDataBuffer &buffer);
52
Q_NETWORK_EXPORT
void
feed
(QByteDataBuffer &&buffer);
53
Q_NETWORK_EXPORT qsizetype
read
(
char
*
data
,
qsizetype
maxSize
);
54
55
Q_NETWORK_EXPORT
bool
isValid
()
const
;
56
57
Q_NETWORK_EXPORT
void
clear
();
58
59
Q_NETWORK_EXPORT
void
setDecompressedSafetyCheckThreshold
(qint64 threshold);
60
61
Q_NETWORK_EXPORT
static
bool
isSupportedEncoding
(QByteArrayView encoding)
noexcept
;
62
Q_NETWORK_EXPORT
static
QByteArrayList
acceptedEncoding
();
63
64
Q_NETWORK_EXPORT QString
errorString
()
const
;
65
66
private
:
67
bool
isPotentialArchiveBomb()
const
;
68
bool
hasDataInternal()
const
;
69
qsizetype readInternal(
char
*data, qsizetype maxSize);
70
71
bool
countInternal();
72
bool
countInternal(
const
QByteArray &data);
73
bool
countInternal(
const
QByteDataBuffer &buffer);
74
75
bool
setEncoding(
ContentEncoding
ce);
76
qint64 encodedBytesAvailable()
const
;
77
78
qsizetype readZLib(
char
*data, qsizetype maxSize);
79
qsizetype readBrotli(
char
*data, qsizetype maxSize);
80
qsizetype readZstandard(
char
*data, qsizetype maxSize);
81
82
QByteDataBuffer compressedDataBuffer;
83
QByteDataBuffer decompressedDataBuffer;
84
const
qsizetype MaxDecompressedDataBufferSize = 10 * 1024 * 1024;
85
bool
decoderHasData =
false
;
86
87
bool
countDecompressed =
false
;
88
std::unique_ptr<QDecompressHelper> countHelper;
89
90
QString errorStr;
91
92
// Used for calculating the ratio
93
qint64 archiveBombCheckThreshold = 10 * 1024 * 1024;
94
qint64 totalUncompressedBytes = 0;
95
qint64 totalCompressedBytes = 0;
96
qint64 totalBytesRead = 0;
97
98
ContentEncoding
contentEncoding =
None
;
99
100
void
*decoderPointer =
nullptr
;
101
#
if
QT_CONFIG
(
brotli
)
102
const
uint8_t
*
brotliUnconsumedDataPtr
=
nullptr
;
103
size_t
brotliUnconsumedAmount
= 0;
104
#
endif
105
};
106
107
QT_END_NAMESPACE
108
109
#
endif
// DECOMPRESS_HELPER_P_H
QDecompressHelper
Definition
qdecompresshelper_p.h:28
QDecompressHelper::setCountingBytesEnabled
Q_NETWORK_EXPORT void setCountingBytesEnabled(bool shouldCount)
Definition
qdecompresshelper.cpp:184
QDecompressHelper::setEncoding
Q_NETWORK_EXPORT bool setEncoding(QByteArrayView contentEncoding)
Definition
qdecompresshelper.cpp:94
QDecompressHelper::feed
Q_NETWORK_EXPORT void feed(const QByteArray &data)
Definition
qdecompresshelper.cpp:222
QDecompressHelper::QDecompressHelper
QDecompressHelper()=default
QDecompressHelper::isSupportedEncoding
static Q_NETWORK_EXPORT bool isSupportedEncoding(QByteArrayView encoding) noexcept
Definition
qdecompresshelper.cpp:74
QDecompressHelper::isValid
Q_NETWORK_EXPORT bool isValid() const
Definition
qdecompresshelper.cpp:510
QDecompressHelper::ContentEncoding
ContentEncoding
Definition
qdecompresshelper_p.h:30
QDecompressHelper::GZip
@ GZip
Definition
qdecompresshelper_p.h:33
QDecompressHelper::None
@ None
Definition
qdecompresshelper_p.h:31
QDecompressHelper::Brotli
@ Brotli
Definition
qdecompresshelper_p.h:34
QDecompressHelper::Zstandard
@ Zstandard
Definition
qdecompresshelper_p.h:35
QDecompressHelper::Deflate
@ Deflate
Definition
qdecompresshelper_p.h:32
QDecompressHelper::hasData
Q_NETWORK_EXPORT bool hasData() const
Definition
qdecompresshelper.cpp:483
QDecompressHelper::setDecompressedSafetyCheckThreshold
Q_NETWORK_EXPORT void setDecompressedSafetyCheckThreshold(qint64 threshold)
Definition
qdecompresshelper.cpp:433
QDecompressHelper::feed
Q_NETWORK_EXPORT void feed(QByteArray &&data)
Definition
qdecompresshelper.cpp:236
QDecompressHelper::isCountingBytes
Q_NETWORK_EXPORT bool isCountingBytes() const
Definition
qdecompresshelper.cpp:166
QDecompressHelper::~QDecompressHelper
Q_NETWORK_EXPORT ~QDecompressHelper()
Definition
qdecompresshelper.cpp:89
QDecompressHelper::clear
Q_NETWORK_EXPORT void clear()
Definition
qdecompresshelper.cpp:526
std
[33]
Definition
src_corelib_tools_qhash.cpp:421
qtbase
src
network
access
qdecompresshelper_p.h
Generated on
for Qt by
1.18.0