GNU bug report logs - #62790
29.0.60; WEBP header regexp in image-type-header-regexps fails files containing newlines

Previous Next

Package: emacs;

Reported by: Visuwesh <visuweshm <at> gmail.com>

Date: Wed, 12 Apr 2023 13:48:02 UTC

Severity: normal

Merged with 62789

Found in version 29.0.60

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 62790 in the body.
You can then email your comments to 62790 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#62790; Package emacs. (Wed, 12 Apr 2023 13:48:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to Visuwesh <visuweshm <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 12 Apr 2023 13:48:03 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Visuwesh <visuweshm <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 29.0.60; WEBP header regexp in image-type-header-regexps fails
 files containing newlines
Date: Wed, 12 Apr 2023 19:17:23 +0530
[Message part 1 (text/plain, inline)]
Attached image contains a newline in the header after "RIFF" which the
regexp in image-type-header-regexps fails to match.  This makes
create-image return nil for such an image when FILE-OR-DATA is DATA and
DATA-P is non-nil.

[004.webp (image/webp, attachment)]
[Message part 3 (text/plain, inline)]
The following patch fixes the issue for me,

diff --git a/lisp/image.el b/lisp/image.el
index 29c39c5dd5..9221057bce 100644
--- a/lisp/image.el
+++ b/lisp/image.el
@@ -51,7 +51,7 @@ image-type-header-regexps
     ("\\`\\(?:MM\0\\*\\|II\\*\0\\)" . tiff)
     ("\\`[\t\n\r ]*%!PS" . postscript)
     ("\\`\xff\xd8" . jpeg)    ; used to be (image-jpeg-p . jpeg)
-    ("\\`RIFF....WEBPVP8" . webp)
+    ("\\`RIFF[^z-a][^z-a][^z-a][^z-a]WEBPVP8" . webp)
     (,(let* ((incomment-re "\\(?:[^-]\\|-[^-]\\)")
 	     (comment-re (concat "\\(?:!--" incomment-re "*-->[ \t\r\n]*<\\)")))
 	(concat "\\(?:<\\?xml[ \t\r\n]+[^>]*>\\)?[ \t\r\n]*<"

[ [^z-a] is documented in (info "(elisp) Regexp Special").  ]


In GNU Emacs 29.0.60 (build 2, x86_64-pc-linux-gnu, X toolkit, Xaw
 scroll bars) of 2023-03-23 built on astatine
Repository revision: be8147c53f9dd2d896c27d5b32bf4f38b0af9b3f
Repository branch: emacs-29
Windowing system distributor 'The X.Org Foundation', version 11.0.12101004
System Description: Debian GNU/Linux bookworm/sid

Configured using:
 'configure --with-sound=alsa --with-x-toolkit=lucid --with-json
 --without-xaw3d --without-gconf --without-libsystemd --without-cairo'
Configured features:
ACL DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG JSON
LIBOTF LIBSELINUX LIBXML2 MODULES NOTIFY INOTIFY PDUMPER PNG RSVG
SECCOMP SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS WEBP X11 XDBE XFT
XIM XINPUT2 XPM LUCID ZLIB
Important settings:
  value of $LC_MONETARY: ta_IN.UTF-8
  value of $LC_NUMERIC: ta_IN.UTF-8
  value of $LANG: en_GB.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes in effect:
  hexl-follow-ascii: t
  csv-field-index-mode: t
  recentf-mode: t
  shell-dirtrack-mode: t
  server-mode: t
  paredit-mode: t
  eros-mode: t
  flymake-mode: t
  pdf-occur-global-minor-mode: t
  minibuffer-depth-indicate-mode: t
  repeat-mode: t
  display-time-mode: t
  display-battery-mode: t
  delete-selection-mode: t
  xterm-mouse-mode: t
  straight-use-package-mode: t
  straight-package-neutering-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  use-hard-newlines: t
  tab-bar-history-mode: t
  tab-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  undelete-frame-mode: t
  transient-mark-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  abbrev-mode: t

Load-path shadows:
None found.

Features:
(ruler-mode hl-line hexl expand-region text-mode-expansions
cc-mode-expansions the-org-mode-expansions python-el-fgallina-expansions
er-basic-expansions expand-region-core ...)

Memory information:
((conses 16 5541494 789498)
 (symbols 48 70186 141)
 (strings 32 495814 72788)
 (string-bytes 1 144111870)
 (vectors 16 216791)
 (vector-slots 8 4288415 706143)
 (floats 8 37436 2621)
 (intervals 56 497259 17293)
 (buffers 976 448))

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#62790; Package emacs. (Wed, 12 Apr 2023 15:53:02 GMT) Full text and rfc822 format available.

Message #8 received at 62790 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Visuwesh <visuweshm <at> gmail.com>
Cc: 62790 <at> debbugs.gnu.org
Subject: Re: bug#62790: 29.0.60;
 WEBP header regexp in image-type-header-regexps fails files
 containing newlines
Date: Wed, 12 Apr 2023 18:53:21 +0300
merge 62790 62789
thanks

> From: Visuwesh <visuweshm <at> gmail.com>
> Date: Wed, 12 Apr 2023 19:17:23 +0530
> 
> Attached image contains a newline in the header after "RIFF" which the
> regexp in image-type-header-regexps fails to match.  This makes
> create-image return nil for such an image when FILE-OR-DATA is DATA and
> DATA-P is non-nil.

Not sure why you filed two identical reports.  Did you send the same
email twice to the bug tracker?




Merged 62789 62790. Request was from Eli Zaretskii <eliz <at> gnu.org> to control <at> debbugs.gnu.org. (Wed, 12 Apr 2023 15:53:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#62790; Package emacs. (Wed, 12 Apr 2023 16:53:02 GMT) Full text and rfc822 format available.

Message #13 received at 62790 <at> debbugs.gnu.org (full text, mbox):

From: Visuwesh <visuweshm <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 62790 <at> debbugs.gnu.org
Subject: Re: bug#62790: 29.0.60; WEBP header regexp in
 image-type-header-regexps fails files containing newlines
Date: Wed, 12 Apr 2023 22:22:29 +0530
[புதன் ஏப்ரல் 12, 2023] Eli Zaretskii wrote:

> merge 62790 62789
> thanks
>
>> From: Visuwesh <visuweshm <at> gmail.com>
>> Date: Wed, 12 Apr 2023 19:17:23 +0530
>> 
>> Attached image contains a newline in the header after "RIFF" which the
>> regexp in image-type-header-regexps fails to match.  This makes
>> create-image return nil for such an image when FILE-OR-DATA is DATA and
>> DATA-P is non-nil.
>
> Not sure why you filed two identical reports.  Did you send the same
> email twice to the bug tracker?

It was an accident.  I was having power cuts every 15 mins, it got me
and I managed to send the mail twice.

[புதன் ஏப்ரல் 12, 2023] Eli Zaretskii wrote:

>> From: Visuwesh <visuweshm <at> gmail.com>
>> Date: Wed, 12 Apr 2023 19:17:13 +0530
>> 
>> Attached image contains a newline in the header after "RIFF" which the
>> regexp in image-type-header-regexps fails to match.  This makes
>> create-image return nil for such an image when FILE-OR-DATA is DATA and
>> DATA-P is non-nil.
>
> Thanks, but please show a recipe, starting from "emacs -Q", to
> reproduce the problem with this image.  I just visited it with
> "C-x C-f" and didn't see any problems.

Please evaluate

    (create-image
        (with-temp-buffer
            (insert-file-contents-literally "/path/to/attached/image")
            (buffer-string))
        nil t)

in emacs -Q and observe the return value.  It will return nil even
though it is a valid webp file.  The reason C-x C-f succeeds is because
the file has the "webp" extension and thusly `image-supported-p' call in
`image-type' returns non-nil.




Reply sent to Eli Zaretskii <eliz <at> gnu.org>:
You have taken responsibility. (Wed, 12 Apr 2023 17:06:02 GMT) Full text and rfc822 format available.

Notification sent to Visuwesh <visuweshm <at> gmail.com>:
bug acknowledged by developer. (Wed, 12 Apr 2023 17:06:02 GMT) Full text and rfc822 format available.

Message #18 received at 62790-done <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Visuwesh <visuweshm <at> gmail.com>
Cc: 62790-done <at> debbugs.gnu.org
Subject: Re: bug#62790: 29.0.60; WEBP header regexp in
 image-type-header-regexps fails files containing newlines
Date: Wed, 12 Apr 2023 20:05:54 +0300
> From: Visuwesh <visuweshm <at> gmail.com>
> Cc: 62790 <at> debbugs.gnu.org
> Date: Wed, 12 Apr 2023 22:22:29 +0530
> 
> [புதன் ஏப்ரல் 12, 2023] Eli Zaretskii wrote:
> 
> > Thanks, but please show a recipe, starting from "emacs -Q", to
> > reproduce the problem with this image.  I just visited it with
> > "C-x C-f" and didn't see any problems.
> 
> Please evaluate
> 
>     (create-image
>         (with-temp-buffer
>             (insert-file-contents-literally "/path/to/attached/image")
>             (buffer-string))
>         nil t)
> 
> in emacs -Q and observe the return value.  It will return nil even
> though it is a valid webp file.  The reason C-x C-f succeeds is because
> the file has the "webp" extension and thusly `image-supported-p' call in
> `image-type' returns non-nil.

Thanks, installed on the emacs-29 branch, and closing the bug.




Reply sent to Eli Zaretskii <eliz <at> gnu.org>:
You have taken responsibility. (Wed, 12 Apr 2023 17:06:03 GMT) Full text and rfc822 format available.

Notification sent to Visuwesh <visuweshm <at> gmail.com>:
bug acknowledged by developer. (Wed, 12 Apr 2023 17:06:03 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 11 May 2023 11:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 41 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.