Skip to content

Commit

Permalink
Added meta sanitization
Browse files Browse the repository at this point in the history
  • Loading branch information
poipoi300 committed Sep 13, 2023
1 parent 5cb84e8 commit d5cb443
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions frontends/krita/krita_diff/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,14 @@ def cb(obj):
for ext_type in {"scripts_txt2img", "scripts_img2img", "scripts_inpaint"}:
metadata: Dict[str, List[dict]] = obj[ext_type]
for ext_name, ext_meta in metadata.items():
# Meta processing to remove lists of lists in multiple choice options
for item in ext_meta:
if item["type"] in ["combo", "multiselect"]:
if isinstance(item['opts'], list) and any(isinstance(opt, list) for opt in item['opts']):
item["opts"] = [opt for sublist in item['opts'] if isinstance(sublist, list) for opt in sublist]
# Remove duplicates from combo and multiselect items
item["opts"] = list(set(item["opts"]))

old_val = self.ext_cfg(get_ext_key(ext_type, ext_name))
new_val = json.dumps(ext_meta)
# Don't overwrite saved script values unless script options changed
Expand Down

0 comments on commit d5cb443

Please sign in to comment.