From 6e82f6f182f585ecc1cc70cd3fe7c5adb6c6c5ea Mon Sep 17 00:00:00 2001 From: Dirk Lemstra Date: Sun, 3 Oct 2021 14:52:29 +0200 Subject: [PATCH] Added extra check to prevent replacing a non-breaking space with a newline. --- magick/annotate.c | 3 ++- magick/token-private.h | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/magick/annotate.c b/magick/annotate.c index 89b81f0d80..d6e339f4e8 100644 --- a/magick/annotate.c +++ b/magick/annotate.c @@ -635,7 +635,8 @@ MagickExport ssize_t FormatMagickCaption(Image *image,DrawInfo *draw_info, q=draw_info->text; continue; } - if (IsUTFSpace(code) != MagickFalse) + if ((IsUTFSpace(code) != MagickFalse) && + (IsNonBreakingUTFSpace(code) == MagickFalse)) { s=p; if (width > image->columns) diff --git a/magick/token-private.h b/magick/token-private.h index a7ca8a0cba..5359de0c6c 100644 --- a/magick/token-private.h +++ b/magick/token-private.h @@ -149,6 +149,13 @@ static inline unsigned int GetUTFOctets(const char *magick_restrict text) return(octets); } +static inline MagickBooleanType IsNonBreakingUTFSpace(int code) +{ + if (code == 0x00a0) + return(MagickTrue); + return(MagickFalse); +} + static inline MagickBooleanType IsUTFSpace(int code) { if (((code >= 0x0009) && (code <= 0x000d)) || (code == 0x0020) ||