mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Enhancement - Sequence range limiting
- Prevents overly large ranges. A bug was reported from a user who tried this: % task annotate 1 1-987654321 The 1-987654321 was assumed to be a valid range, and caused task to consume all available memory. The workaround was: % task 1 annotate 1-987654321 But it seems a good idea to range-limit sequences. Currently it is 1000. Perhaps this should be configurable.
This commit is contained in:
parent
f3724aa714
commit
8fa38fc4c3
3 changed files with 5 additions and 3 deletions
|
@ -83,8 +83,8 @@ void Sequence::parse (const std::string& input)
|
|||
if (low > high)
|
||||
throw std::string ("Inverted sequence range high-low");
|
||||
|
||||
if (high - low > 1000)
|
||||
throw std::string ("Range too large, exceeded 1,000 IDs");
|
||||
if (high - low >= SEQUENCE_MAX)
|
||||
throw std::string ("ID Range too large");
|
||||
|
||||
for (int i = low; i <= high; ++i)
|
||||
this->push_back (i);
|
||||
|
|
|
@ -30,6 +30,8 @@
|
|||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#define SEQUENCE_MAX 1000
|
||||
|
||||
class Sequence : public std::vector <int>
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -90,7 +90,7 @@ int main (int argc, char** argv)
|
|||
seq = parseSequence ("1--2");
|
||||
t.is (seq.size (), (size_t)0, "seq '1--2' -> 0 items (error)");
|
||||
|
||||
// 1-1000
|
||||
// 1-1000 (SEQUENCE_MAX);
|
||||
seq = parseSequence ("1-1000");
|
||||
t.is (seq.size (), (size_t)1000, "seq '1-1000' -> 1000 items");
|
||||
if (seq.size () == 1000)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue