mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-03-14 11:07:45 +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
|
||||
*/
|
||||
|
||||
bool CSV::readEntry(QByteArrayList &list)
|
||||
bool CSV::readEntry(QByteArrayList &list, int limit)
|
||||
{
|
||||
int state = 0;
|
||||
int state = 0, len = 0;
|
||||
char c;
|
||||
QByteArray field;
|
||||
|
||||
list.clear();
|
||||
|
||||
while (_device->getChar(&c)) {
|
||||
if (limit && ++len > limit)
|
||||
return false;
|
||||
|
||||
switch (state) {
|
||||
case 0:
|
||||
if (c == '\r')
|
||||
|
@ -9,7 +9,7 @@ public:
|
||||
CSV(QIODevice *device, char delimiter = ',')
|
||||
: _device(device), _delimiter(delimiter), _line(1) {}
|
||||
|
||||
bool readEntry(QByteArrayList &list);
|
||||
bool readEntry(QByteArrayList &list, int limit = 4096);
|
||||
bool atEnd() const {return _device->atEnd();}
|
||||
int line() const {return _line;}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user