home · contact · privacy
Fix POST /todo crashing on non-intable 'fill_for_' adoption values.
authorChristian Heller <c.heller@plomlompom.de>
Thu, 18 Jul 2024 00:56:18 +0000 (02:56 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Thu, 18 Jul 2024 00:56:18 +0000 (02:56 +0200)
plomtask/http.py

index 2aa521566bbbf8ebcf5297dadfa25a661e7d1658..c7678a780dc0af7f6caa304dfb47b143b7346be9 100644 (file)
@@ -646,20 +646,21 @@ class TaskHandler(BaseHTTPRequestHandler):
         comment = self._form_data.get_str('comment', ignore_strict=True)
         for v in fill_fors.values():
             target_id: int
-            for prefix in ['make_empty_', 'make_full_']:
-                if v.startswith(prefix):
-                    try:
-                        target_id = int(v[len(prefix):])
-                    except ValueError as e:
-                        msg = 'bad fill_for target: {v}'
-                        raise BadFormatException(msg) from e
-                    continue
+            to_int = v
+            for prefix in [p for p in ['make_empty_', 'make_full_']
+                           if v.startswith(p)]:
+                to_int = v[len(prefix):]
+            try:
+                target_id = int(to_int)
+            except ValueError as e:
+                msg = 'bad fill_for target: {v}'
+                raise BadFormatException(msg) from e
             if v.startswith('make_empty_'):
                 processes_to_make_empty += [target_id]
             elif v.startswith('make_full_'):
                 processes_to_make_full += [target_id]
             elif v != 'ignore':
-                adopted_child_ids += [int(v)]
+                adopted_child_ids += [target_id]
         to_remove = []
         for child in todo.children:
             assert isinstance(child.id_, int)