Ignore invalid palettes (#1718)

pull/1721/head
Kaalleen 2022-07-04 13:13:05 +02:00 zatwierdzone przez GitHub
rodzic 4c3a11bb82
commit 8d9a469ae2
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
3 zmienionych plików z 11 dodań i 1 usunięć

Wyświetl plik

@ -27,6 +27,10 @@ class PaletteToText(InkstitchExtension):
return
thread_palette = ThreadPalette(palette_file)
if not thread_palette.is_gimp_palette:
inkex.errormsg(_("Cannot read palette: invalid GIMP palette header"))
return
current_layer = self.svg.get_current_layer()
x = 0

Wyświetl plik

@ -42,6 +42,9 @@ class _ThreadCatalog(Sequence):
for palette_file in glob(os.path.join(path, 'InkStitch*.gpl')):
palette_basename = os.path.basename(palette_file)
if palette_basename not in palettes:
palette = ThreadPalette(palette_file)
if not palette.is_gimp_palette:
continue
self.palettes.append(ThreadPalette(palette_file))
palettes.append(palette_basename)

Wyświetl plik

@ -40,8 +40,11 @@ class ThreadPalette(Set):
with open(palette_file, encoding='utf8') as palette:
line = palette.readline().strip()
self.is_gimp_palette = True
if line.lower() != "gimp palette":
raise ValueError("Invalid gimp palette header")
self.is_gimp_palette = False
return
self.name = palette.readline().strip()
if self.name.lower().startswith('name: ink/stitch: '):