Commit e1fdb94
authored
Limit number of parts of a key (#286)
* Limit number of parts of a key
tomli has quadratic time complexity when handling parts of a key
(via Flags.is_ calls in key_value_rule's loop, and maybe elsewhere).
This isn't a problem unless a document has an excessive number (10_000-ish)
of parts in a key. Limiting input seems like the best fix here.
`sys.getrecursionlimit` and `RecursionError` is already (and in the non-mypyc
version, implicitly) used for `MAX_INLINE_NESTING`.
Keys aren't parsed recursively, but that's an implementation detail;
`RecursionError` works nicely for names recursive structures.1 parent c20c491 commit e1fdb94
2 files changed
Lines changed: 28 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
37 | 44 | | |
38 | 45 | | |
39 | 46 | | |
| |||
475 | 482 | | |
476 | 483 | | |
477 | 484 | | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
478 | 489 | | |
479 | 490 | | |
480 | 491 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
130 | 130 | | |
131 | 131 | | |
132 | 132 | | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
133 | 150 | | |
134 | 151 | | |
135 | 152 | | |
| |||
0 commit comments