From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: David Ponce Newsgroups: gmane.emacs.bugs Subject: bug#65496: 30.0.50; Issue with the regexp used to auto-detect PBM image data Date: Thu, 24 Aug 2023 12:55:03 +0200 Message-ID: <2fea228e-a8e8-5b8e-b91d-2d808d624649@orange.fr> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------D0ZDEeHl1sZXilCxsFxaFTlT" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="27613"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.14.0 To: 65496@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Aug 24 12:56:21 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qZ80i-0006ss-UL for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 24 Aug 2023 12:56:21 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qZ80P-0002xN-6G; Thu, 24 Aug 2023 06:56:01 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qZ80N-0002xB-2T for bug-gnu-emacs@gnu.org; Thu, 24 Aug 2023 06:55:59 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qZ80M-0006Ym-Q9 for bug-gnu-emacs@gnu.org; Thu, 24 Aug 2023 06:55:58 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qZ80Q-0007Yk-M3 for bug-gnu-emacs@gnu.org; Thu, 24 Aug 2023 06:56:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: David Ponce Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 24 Aug 2023 10:56:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 65496 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.169287452829011 (code B ref -1); Thu, 24 Aug 2023 10:56:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 24 Aug 2023 10:55:28 +0000 Original-Received: from localhost ([127.0.0.1]:36254 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qZ7zs-0007Xq-6v for submit@debbugs.gnu.org; Thu, 24 Aug 2023 06:55:28 -0400 Original-Received: from lists.gnu.org ([2001:470:142::17]:57764) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qZ7zn-0007Xa-TQ for submit@debbugs.gnu.org; Thu, 24 Aug 2023 06:55:27 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qZ7ze-0002vz-E4 for bug-gnu-emacs@gnu.org; Thu, 24 Aug 2023 06:55:14 -0400 Original-Received: from smtp-15.smtpout.orange.fr ([80.12.242.15] helo=smtp.smtpout.orange.fr) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qZ7zY-0006PG-LX for bug-gnu-emacs@gnu.org; Thu, 24 Aug 2023 06:55:14 -0400 Original-Received: from [192.168.1.15] ([2.7.71.181]) by smtp.orange.fr with ESMTPA id Z7zTqUnKG9KIfZ7zUqv7YT; Thu, 24 Aug 2023 12:55:04 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=orange.fr; s=t20230301; t=1692874504; bh=a0rhOg4Gx5s3YAYYVjWZ2A5NgmgLwKpK99Vf/v+sxI8=; h=Date:To:From:Subject; b=NYHt6iCv8X4Ke+9gTDzzCMPoSZImzJhjYwzpr8eqd0/T/QQYRo/pCh9A3BROWg13B jbE7sLoWnmOvXSkk9aF2tk/FAXar9aYvkNpGhh0BLnHr3xiJgGZoJeumIaDgUPz/Xx EJ03HWDQTa2IPTOPt7XquMEvF1fvWdRhVwwkMHBU1CrAYrN8gQ/4udBsQMI5ci7PEu qVCe9Pj1VzMDbdxrkVbAj2+lOklxz9dWdDVPthGZwT5WooOQkdYBrKyvL5XVyK2TcZ 0N6RPSN5094+zp/54BB79RBQ0BPp8qh7TuKwMlULdgXPPrMBOsG+gmSOFy5PniEYej 5Y1OI2Wy+elEA== X-ME-Helo: [192.168.1.15] X-ME-Auth: ZGFfdmlkQHdhbmFkb28uZnI= X-ME-Date: Thu, 24 Aug 2023 12:55:04 +0200 X-ME-IP: 2.7.71.181 Content-Language: fr, en-US Received-SPF: pass client-ip=80.12.242.15; envelope-from=da_vid@orange.fr; helo=smtp.smtpout.orange.fr X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:268324 Archived-At: This is a multi-part message in MIME format. --------------D0ZDEeHl1sZXilCxsFxaFTlT Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Hello, While experimenting with code to create image from data, I encountered an issue with the regexp in `image-type-header-regexps' used to auto-detect PBM image type from the first bytes of image data. That is: "\\`P[1-6]\\(?:\ \\(?:\\(?:#[^\r\n]*[\r\n]\\)*[[:space:]]\\)+\ \\(?:\\(?:#[^\r\n]*[\r\n]\\)*[0-9]\\)+\ \\)\\{2\\}" Here is a simple recipe to illustrate the issue: In *scratch* buffer eval: ------------------------- ;; Get content of a pbm file. (setq test-data (with-current-buffer (find-file-noselect "[YourEmacsPath]/etc/images/splash.pbm") (prog1 (buffer-substring-no-properties (point-min) (point-max)) (kill-buffer (current-buffer))))) ;; Check string data fail for pbm image-type! (image-type-from-data test-data) >>> nil ;; With a temp buffer current, the same test works! (with-temp-buffer (image-type-from-data test-data)) >>> pbm ------------------------- After further digging, I found that the problem might be due to the use of the [:space:] character class whose meaning, according to the manual, depends on the syntax of whitespace characters setup in current buffer. So, using discrete values in place of syntax class seems to solve the issue: (setcar (nth 1 image-type-header-regexps) "\\`P[1-6]\\(?:\ \\(?:\\(?:#[^\r\n]*[\r\n]\\)*[ \t\r\n]\\)+\ \\(?:\\(?:#[^\r\n]*[\r\n]\\)*[0-9]\\)+\ \\)\\{2\\}") (image-type-from-data test-data) >>> pbm I attached a patch proposal. Hope it will help. Regards In GNU Emacs 30.0.50 (build 3, x86_64-pc-linux-gnu, GTK+ Version 3.24.38, cairo version 1.17.8) of 2023-08-23 Repository revision: 26ca3e84e167f975afb4e9e9a838935bfe4a19a7 Repository branch: master Windowing system distributor 'The X.Org Foundation', version 11.0.12014000 System Description: Fedora Linux 38 (KDE Plasma) Configured using: 'configure --with-x-toolkit=gtk3 --with-native-compilation=no PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/lib/pkgconfig' Configured features: ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG JSON LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS TREE_SITTER WEBP X11 XDBE XIM XINPUT2 XPM GTK3 ZLIB Important settings: value of $LC_TIME: fr_FR.utf8 value of $LANG: fr_FR.UTF-8 locale-coding-system: utf-8-unix --------------D0ZDEeHl1sZXilCxsFxaFTlT Content-Type: text/x-patch; charset=UTF-8; name="image-type-header-regexps-patch-V0.patch" Content-Disposition: attachment; filename="image-type-header-regexps-patch-V0.patch" Content-Transfer-Encoding: base64 ZGlmZiAtLWdpdCBhL2xpc3AvaW1hZ2UuZWwgYi9saXNwL2ltYWdlLmVsCmluZGV4IDA4MTkw Y2Y4NmJjLi5lMjBmYmNmNGM5OCAxMDA2NDQKLS0tIGEvbGlzcC9pbWFnZS5lbAorKysgYi9s aXNwL2ltYWdlLmVsCkBAIC0zOCw3ICszOCw3IEBAIGltYWdlCiAoZGVmY29uc3QgaW1hZ2Ut dHlwZS1oZWFkZXItcmVnZXhwcwogICBgKCgiXFxgL1tcdFxuXHIgXSpcXCouKlhQTS5cXCov IiAuIHhwbSkKICAgICAoIlxcYFBbMS02XVxcKD86XAotXFwoPzpcXCg/OiNbXlxyXG5dKltc clxuXVxcKSpbWzpzcGFjZTpdXVxcKStcCitcXCg/OlxcKD86I1teXHJcbl0qW1xyXG5dXFwp KlsgXHRcclxuXVxcKStcCiBcXCg/OlxcKD86I1teXHJcbl0qW1xyXG5dXFwpKlswLTldXFwp K1wKIFxcKVxcezJcXH0iIC4gcGJtKQogICAgICgiXFxgR0lGOFs3OV1hIiAuIGdpZikK --------------D0ZDEeHl1sZXilCxsFxaFTlT--