https://github.com/ImageMagick/ImageMagick/issues/966
diff --git a/coders/html.c b/coders/html.c
index 53a9a0e..2ed89f9 100644
--- a/coders/html.c
+++ b/coders/html.c
@@ -334,7 +334,8 @@
       (void) FormatLocaleString(buffer,MagickPathExtent,
         "<map id=\"%s\" name=\"%s\">\n",mapname,mapname);
       (void) WriteBlobString(image,buffer);
-      (void) FormatLocaleString(buffer,MagickPathExtent,"  <area href=\"%s",url);
+      (void) FormatLocaleString(buffer,MagickPathExtent,"  <area href=\"%s",
+        url);
       (void) WriteBlobString(image,buffer);
       if (image->directory == (char *) NULL)
         {
@@ -346,7 +347,7 @@
         }
       else
         for (p=image->directory; *p != '\0'; p++)
-          if (*p != '\n')
+          if (*p != '\377')
             (void) WriteBlobByte(image,(unsigned char) *p);
           else
             {
@@ -421,7 +422,7 @@
     }
   else
     for (p=image->directory; *p != '\0'; p++)
-      if (*p != '\n')
+      if (*p != '\377')
         (void) WriteBlobByte(image,(unsigned char) *p);
       else
         {
diff --git a/coders/json.c b/coders/json.c
index eda1206..6ee4b29 100644
--- a/coders/json.c
+++ b/coders/json.c
@@ -1502,7 +1502,7 @@
       while (*p != '\0')
       {
         q=p;
-        while ((*q != '\n') && (*q != '\0'))
+        while ((*q != '\377') && (*q != '\0'))
           q++;
         (void) CopyMagickString(image_info->filename,p,(size_t) (q-p+1));
         p=q+1;