Limit the number of drawing primitives to 100000

to avoid people trashing the server with too complicated drawings
This commit is contained in:
Florian Festi 2023-02-07 21:54:38 +01:00
parent 64dca171b4
commit 455f5ae69a
1 changed files with 4 additions and 0 deletions

View File

@ -34,6 +34,7 @@ class Surface:
self._fname = fname
self.parts: list[Any] = []
self._p = self.new_part("default")
self.count = 0
def set_metadata(self, metadata):
self.metadata = metadata
@ -81,6 +82,9 @@ class Surface:
return p
def append(self, *path):
self.count += 1
if self.count > 100000:
raise ValueError("Too many lines")
self._p.append(*path)
def stroke(self, **params):