mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-03-14 19:17:44 +01:00
Limit maximal allowed CSV entries size
This commit is contained in:
parent
17ad10ba23
commit
c5f51e935e
@ -7,15 +7,18 @@ RFC 4180 parser with the following enchancements:
|
|||||||
- allows LF line ends in addition to CRLF line ends
|
- allows LF line ends in addition to CRLF line ends
|
||||||
*/
|
*/
|
||||||
|
|
||||||
bool CSV::readEntry(QByteArrayList &list)
|
bool CSV::readEntry(QByteArrayList &list, int limit)
|
||||||
{
|
{
|
||||||
int state = 0;
|
int state = 0, len = 0;
|
||||||
char c;
|
char c;
|
||||||
QByteArray field;
|
QByteArray field;
|
||||||
|
|
||||||
list.clear();
|
list.clear();
|
||||||
|
|
||||||
while (_device->getChar(&c)) {
|
while (_device->getChar(&c)) {
|
||||||
|
if (limit && ++len > limit)
|
||||||
|
return false;
|
||||||
|
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case 0:
|
case 0:
|
||||||
if (c == '\r')
|
if (c == '\r')
|
||||||
|
@ -9,7 +9,7 @@ public:
|
|||||||
CSV(QIODevice *device, char delimiter = ',')
|
CSV(QIODevice *device, char delimiter = ',')
|
||||||
: _device(device), _delimiter(delimiter), _line(1) {}
|
: _device(device), _delimiter(delimiter), _line(1) {}
|
||||||
|
|
||||||
bool readEntry(QByteArrayList &list);
|
bool readEntry(QByteArrayList &list, int limit = 4096);
|
||||||
bool atEnd() const {return _device->atEnd();}
|
bool atEnd() const {return _device->atEnd();}
|
||||||
int line() const {return _line;}
|
int line() const {return _line;}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user