Commit b0f2b63c2 for imagemagick.org

commit b0f2b63c29a36839ae252865203c9b4ed31e2f48
Author: Cristy <urban-warrior@imagemagick.org>
Date:   Tue Dec 1 19:37:25 2026 -0500

    HTTPS was never unregistered

diff --git a/coders/url.c b/coders/url.c
index 1c6951bb9..cc406aaa1 100644
--- a/coders/url.c
+++ b/coders/url.c
@@ -51,6 +51,7 @@
 #include "MagickCore/image.h"
 #include "MagickCore/image-private.h"
 #include "MagickCore/list.h"
+#include "MagickCore/log.h"
 #include "MagickCore/magick.h"
 #include "MagickCore/memory_.h"
 #include "MagickCore/module.h"
@@ -126,23 +127,31 @@ static Image *InvokeURLDelegate(ImageInfo *read_info,Image *image,

 static Image *ReadURLImage(const ImageInfo *image_info,ExceptionInfo *exception)
 {
-  char
-    filename[MagickPathExtent];
-
-  FILE
-    *file;
-
   Image
     *image,
-    *images,
-    *next;
+    *images;

   ImageInfo
     *read_info;

+#if defined(MAGICKCORE_WINDOWS_SUPPORT)
+  char
+    filename[MagickPathExtent];
+
+  Image
+    *next;
+
   int
     unique_file;
+#endif

+  assert(image_info != (const ImageInfo *) NULL);
+  assert(image_info->signature == MagickCoreSignature);
+  assert(exception != (ExceptionInfo *) NULL);
+  assert(exception->signature == MagickCoreSignature);
+  if (IsEventLogging() != MagickFalse)
+    (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
+      image_info->filename);
   images=(Image *) NULL;
   image=AcquireImage(image_info,exception);
   read_info=CloneImageInfo(image_info);
@@ -165,19 +174,26 @@ static Image *ReadURLImage(const ImageInfo *image_info,ExceptionInfo *exception)
 #endif
   if (LocaleCompare(read_info->magick,"file") == 0)
     {
-      (void) CopyMagickString(read_info->filename,image_info->filename+2,
-        MagickPathExtent);
+      const char
+        *path;
+
+      /*
+        Strip the "//" authority marker only when it is actually present
+        (file://path); "file:path" and "file:/path" are left intact.
+      */
+      path=image_info->filename;
+      if (strncmp(path,"//",2) == 0)
+        path+=2;
+      (void) CopyMagickString(read_info->filename,path,MagickPathExtent);
       *read_info->magick='\0';
       images=ReadImageWithoutPostProcessing(read_info,exception);
       read_info=DestroyImageInfo(read_info);
       image=DestroyImage(image);
       return(GetFirstImageInList(images));
     }
-  file=(FILE *) NULL;
+#if defined(MAGICKCORE_WINDOWS_SUPPORT)
   unique_file=AcquireUniqueFileResource(read_info->filename);
-  if (unique_file != -1)
-    file=fdopen(unique_file,"wb");
-  if ((unique_file == -1) || (file == (FILE *) NULL))
+  if (unique_file == -1)
     {
       ThrowFileException(exception,FileOpenError,"UnableToCreateTemporaryFile",
         read_info->filename);
@@ -185,13 +201,12 @@ static Image *ReadURLImage(const ImageInfo *image_info,ExceptionInfo *exception)
       image=DestroyImage(image);
       return((Image *) NULL);
     }
+  (void) close(unique_file);
   (void) CopyMagickString(filename,image_info->magick,MagickPathExtent);
   (void) ConcatenateMagickString(filename,":",MagickPathExtent);
   LocaleLower(filename);
   (void) ConcatenateMagickString(filename,image_info->filename,
     MagickPathExtent);
-#if defined(MAGICKCORE_WINDOWS_SUPPORT)
-  (void) fclose(file);
   if (URLDownloadToFile(NULL,filename,read_info->filename,0,NULL) != S_OK)
     {
       ThrowFileException(exception,FileOpenError,"UnableToOpenFile",
@@ -201,9 +216,6 @@ static Image *ReadURLImage(const ImageInfo *image_info,ExceptionInfo *exception)
       image=DestroyImage(image);
       return((Image *) NULL);
     }
-#else
-  (void) fclose(file);
-#endif
   *read_info->magick='\0';
   images=ReadImageWithoutPostProcessing(read_info,exception);
   (void) RelinquishUniqueFileResource(read_info->filename);
@@ -221,7 +233,19 @@ static Image *ReadURLImage(const ImageInfo *image_info,ExceptionInfo *exception)
       return((Image *) NULL);
     }
   return(GetFirstImageInList(images));
+#else
+  /*
+    Only http, https, and file are handled natively on this platform; there is
+    nothing sensible to download any other scheme with.
+  */
+  read_info=DestroyImageInfo(read_info);
+  image=DestroyImage(image);
+  (void) ThrowMagickException(exception,GetMagickModule(),MissingDelegateError,
+    "NoDecodeDelegateForThisImageFormat","`%s'",image_info->magick);
+  return((Image *) NULL);
+#endif
 }
+

 /*
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -294,6 +318,7 @@ ModuleExport size_t RegisterURLImage(void)
 ModuleExport void UnregisterURLImage(void)
 {
   (void) UnregisterMagickInfo("HTTP");
+  (void) UnregisterMagickInfo("HTTPS");
   (void) UnregisterMagickInfo("FTP");
   (void) UnregisterMagickInfo("FILE");
 }