Commit 64d2e4a20 for imagemagick.org
commit 64d2e4a208c2280c64543a342d5284cd910f5230
Author: Cristy <urban-warrior@imagemagick.org>
Date: Sat Jun 27 07:38:40 2026 -0400
https://github.com/ImageMagick/ImageMagick/issues/8823
diff --git a/MagickCore/image.c b/MagickCore/image.c
index 58f0b1555..91d44dbdf 100644
--- a/MagickCore/image.c
+++ b/MagickCore/image.c
@@ -86,6 +86,7 @@
#include "MagickCore/property.h"
#include "MagickCore/quantize.h"
#include "MagickCore/random_.h"
+#include "MagickCore/registry.h"
#include "MagickCore/resource_.h"
#include "MagickCore/segment.h"
#include "MagickCore/semaphore.h"
@@ -1697,6 +1698,7 @@ MagickExport size_t InterpretImageFilename(const ImageInfo *image_info,
ExceptionInfo *exception)
{
char
+ *literal,
*p = filename,
pattern[MagickPathExtent];
@@ -1705,11 +1707,17 @@ MagickExport size_t InterpretImageFilename(const ImageInfo *image_info,
assert(format != (const char *) NULL);
assert(filename != (char *) NULL);
- if (IsStringTrue(GetImageOption(image_info,"filename:literal")) != MagickFalse)
+ literal=(char *) GetImageRegistry(StringRegistryType,"filename:literal",
+ exception);
+ if (IsStringTrue(literal) != MagickFalse)
{
+ if (literal != (char *) NULL)
+ literal=DestroyString(literal);
(void) CopyMagickString(filename,format,MagickPathExtent);
return(strlen(filename));
}
+ if (literal != (char *) NULL)
+ literal=DestroyString(literal);
while ((*cursor != '\0') && ((p-filename) < ((ssize_t) MagickPathExtent-1)))
{
const char
@@ -2985,13 +2993,17 @@ MagickExport MagickBooleanType SetImageInfo(ImageInfo *image_info,
(delegate_info != (const DelegateInfo *) NULL)) &&
(IsMagickConflict(magic) == MagickFalse))
{
+ char *literal = (char *) GetImageRegistry(StringRegistryType,
+ "filename:literal",exception);
image_info->affirm=MagickTrue;
(void) CopyMagickString(image_info->magick,magic,MagickPathExtent);
GetPathComponent(image_info->filename,CanonicalPath,component);
- if (IsStringTrue(GetImageOption(image_info,"filename:literal")) != MagickFalse)
+ if (IsStringTrue(literal) != MagickFalse)
GetPathComponent(image_info->filename,SubcanonicalPath,component);
(void) CopyMagickString(image_info->filename,component,
MagickPathExtent);
+ if (literal != (char *) NULL)
+ literal=DestroyString(literal);
}
}
sans_exception=DestroyExceptionInfo(sans_exception);
diff --git a/MagickCore/option.c b/MagickCore/option.c
index 31be5efe4..430066424 100644
--- a/MagickCore/option.c
+++ b/MagickCore/option.c
@@ -2444,6 +2444,13 @@ MagickExport MagickBooleanType DefineImageOption(ImageInfo *image_info,
if (*p == '=')
(void) CopyMagickString(value,p+1,MagickPathExtent);
*p='\0';
+ if (LocaleCompare(key,"filename:literal") == 0)
+ {
+ ExceptionInfo *exception = AcquireExceptionInfo();
+ (void) SetImageRegistry(StringRegistryType,key,value,
+ exception);
+ exception=DestroyExceptionInfo(exception);
+ }
return(SetImageOption(image_info,key,value));
}
diff --git a/MagickCore/utility.c b/MagickCore/utility.c
index e989d9ee3..58a46beee 100644
--- a/MagickCore/utility.c
+++ b/MagickCore/utility.c
@@ -1291,8 +1291,13 @@ MagickExport void GetPathComponent(const char *path,PathType type,
p=component+strlen(component)-1;
if ((strlen(component) > 2) && (*p == ']'))
{
+ ExceptionInfo *exception = AcquireExceptionInfo();
+ char *literal = (char *) GetImageRegistry(StringRegistryType,
+ "filename:literal",exception);
q=strrchr(component,'[');
- if ((q != (char *) NULL) && (IsPathAccessible(path) == MagickFalse))
+ if ((q != (char *) NULL) &&
+ ((IsStringTrue(literal) == MagickFalse) ||
+ (IsPathAccessible(path) == MagickFalse)))
{
/*
Look for scene specification (e.g. img0001.pcd[4]).
@@ -1308,6 +1313,9 @@ MagickExport void GetPathComponent(const char *path,PathType type,
*q='\0';
}
}
+ if (literal != (char *) NULL)
+ literal=DestroyString(literal);
+ exception=DestroyExceptionInfo(exception);
}
}
magick_length=0;
diff --git a/coders/json.c b/coders/json.c
index cd886485b..9ed118f8e 100644
--- a/coders/json.c
+++ b/coders/json.c
@@ -1683,12 +1683,16 @@ static MagickBooleanType EncodeImageAttributes(Image *image,FILE *file,
n=0;
while (registry != (const char *) NULL)
{
+ char *registry_value = (char *) GetImageRegistry(StringRegistryType,
+ registry,exception);
if (n++ != 0)
(void) FormatLocaleFile(file,",\n");
JSONFormatLocaleFile(file," %s: ",registry);
- value=(const char *) GetImageRegistry(StringRegistryType,registry,
- exception);
- JSONFormatLocaleFile(file,"%s",value);
+ if (registry_value != (char *) NULL)
+ {
+ JSONFormatLocaleFile(file,"%s",registry_value);
+ registry_value=DestroyString(registry_value);
+ }
registry=GetNextImageRegistry();
}
(void) FormatLocaleFile(file," },\n");
diff --git a/coders/yaml.c b/coders/yaml.c
index bc35a93c1..b3dc3559d 100644
--- a/coders/yaml.c
+++ b/coders/yaml.c
@@ -1649,12 +1649,17 @@ static MagickBooleanType EncodeImageAttributes(Image *image,FILE *file,
n=0;
while (registry != (const char *) NULL)
{
+ char *registry_value = (char *) GetImageRegistry(StringRegistryType,
+ registry,exception);
if (n++ != 0)
(void) FormatLocaleFile(file,"\n");
YAMLFormatLocaleFile(file," %s: ",registry);
- value=(const char *) GetImageRegistry(StringRegistryType,registry,
- exception);
- YAMLFormatLocaleFile(file,"%s",value);
+ if (registry_value != (char *) NULL)
+ {
+ YAMLFormatLocaleFile(file,"%s",registry_value);
+ registry_value=DestroyString(registry_value);
+ }
+ YAMLFormatLocaleFile(file,"%s",registry_value);
registry=GetNextImageRegistry();
}
(void) FormatLocaleFile(file," \n");