Strengthen paste logic

This commit is contained in:
GenevensiS
2026-05-11 13:51:43 +02:00
committed by GitHub
parent 2135a14b17
commit f4fe9ab6b0
9 changed files with 497 additions and 375 deletions
+3 -6
View File
@@ -850,14 +850,11 @@ DownloadedImage::DownloadedImage(Set* set, const String& url)
}
// is the data an image?
const String& content_type = wnd.out.GetContentType();
if (!content_type.StartsWith(_("image"))) throw ScriptError(_ERROR_1_("download not image", loadpath));
Image img(*wnd.out.GetStream());
if (!img.IsOk()) throw ScriptError(_ERROR_("web request corrupted"));
if (!wnd.content_type.StartsWith(_("image/"))) throw ScriptError(_ERROR_1_("download not image", loadpath));
// add the file to the set (or overwrite it if pre-existing), save set
auto outStream = set->openOut(savename);
img.SaveFile(*outStream, wxBITMAP_TYPE_PNG);
wnd.image_out.SaveFile(*outStream, wxBITMAP_TYPE_PNG);
if (!outStream->IsOk()) throw ScriptError(_ERROR_1_("can't write image to set", loadpath));
outStream->Close();
set->save(false);