Subject: Re: bug#28824: 26.0.90; display of pbm images broken?

From: Andy Moreton <[email-masked]>
Date: Sat, 14 Oct 2017 20:03:27 +0100

On Sat 14 Oct 2017, Andy Moreton wrote:

> On Sat 14 Oct 2017, Eli Zaretskii wrote:
>
>>> From: Andy Moreton <[email-masked]>
>>> Date: Sat, 14 Oct 2017 16:01:20 +0100
>>> 
>>> I see problems with some PBM files from etc/images with emacs 26.0.90 on
>>> Windows. The ones that don't work appear to be those that contain a
>>> Netpbm header, e.g. back-arrow.pbm close.pbm cut.pbm fwd-arrow.pbm
>>> home.pbm
>>
>> I see no problems with those images you mention as problematic.
>>
>> Could it be a problem specific to 64-bit builds?
>
> I've tried this in a 32bit MinGW build with the same results. It appears
> to be a problem with the pbm entry in image-type-header-regexps, as
> doing (setq image-type-header-regexps '(("\\`P[1-6]" . pbm))) results in
> the problematic images displaying correctly.
>
>     AndyM

The file format is described at http://netpbm.sourceforge.net/doc/pbm.html

Further testing with the images from etc/images in emacs 26 shows that
this patch appears to fix the problem:

diff --git a/lisp/image.el b/lisp/image.el
index 1d0776180b..32df508bc8 100644
--- a/lisp/image.el
+++ b/lisp/image.el
@@ -34,8 +34,8 @@ 'image-refresh
 (defconst image-type-header-regexps
   `(("\\`/[\t\n\r ]*\\*.*XPM.\\*/" . xpm)
     ("\\`P[1-6]\\(?:\
-\\(?:\\(?:#[^\r\n]*[\r\n]\\)?[[:space:]]\\)+\
-\\(?:\\(?:#[^\r\n]*[\r\n]\\)?[0-9]\\)+\
+\\(?:\\(?:#[^\r\n]*[\r\n]\\)*[[:space:]]\\)+\
+\\(?:\\(?:#[^\r\n]*[\r\n]\\)*[0-9]\\)+\
 \\)\\{2\\}" . pbm)
     ("\\`GIF8[79]a" . gif)
     ("\\`\x89PNG\r\n\x1a\n" . png)