From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Philip Kaludercic Newsgroups: gmane.emacs.bugs Subject: bug#54263: 29.0.50; color-values-from-color-spec accepts whitespace in rgbi: specifications Date: Sun, 06 Mar 2022 10:45:44 +0000 Message-ID: <875yore4vb.fsf@posteo.net> References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="33785"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 54263@debbugs.gnu.org, Lars Ingebrigtsen To: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Mar 06 11:46:28 2022 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 1nQoPD-0008a1-RI for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 06 Mar 2022 11:46:27 +0100 Original-Received: from localhost ([::1]:46114 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQoPC-0003gH-51 for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 06 Mar 2022 05:46:26 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:51474) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQoOo-0003g8-NJ for bug-gnu-emacs@gnu.org; Sun, 06 Mar 2022 05:46:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:56049) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nQoOo-0003PA-Ee for bug-gnu-emacs@gnu.org; Sun, 06 Mar 2022 05:46:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nQoOo-00013I-5U for bug-gnu-emacs@gnu.org; Sun, 06 Mar 2022 05:46:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Philip Kaludercic Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 06 Mar 2022 10:46:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 54263 X-GNU-PR-Package: emacs Original-Received: via spool by 54263-submit@debbugs.gnu.org id=B54263.16465635544029 (code B ref 54263); Sun, 06 Mar 2022 10:46:02 +0000 Original-Received: (at 54263) by debbugs.gnu.org; 6 Mar 2022 10:45:54 +0000 Original-Received: from localhost ([127.0.0.1]:49946 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nQoOg-00012v-3a for submit@debbugs.gnu.org; Sun, 06 Mar 2022 05:45:54 -0500 Original-Received: from mout02.posteo.de ([185.67.36.66]:46257) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nQoOe-00012g-66 for 54263@debbugs.gnu.org; Sun, 06 Mar 2022 05:45:53 -0500 Original-Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 992F3240105 for <54263@debbugs.gnu.org>; Sun, 6 Mar 2022 11:45:45 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1646563545; bh=H/iK+14S5n5e3TuhyJPIvQ0DmvOcyWG0yTdMImHSSF0=; h=From:To:Cc:Subject:Autocrypt:Date:From; b=HX4w/9x6sxegvecAvwE5kiVFzyc+CleVDk4vodx/slzjyvUQK+uhfp2YtTcUyeA6c Q3Nkb+3WkQJFW/gcVBxE3oMK/9X/rUwRnfFAX5pskCjL7GqwZMF63Fp0GMdVTfVrNN h/MOIx+yUJjumSloBVW2aelpmLyzJ7wbc2eHjzvU8tIm3EF5rqLe+JpKrV5KtjZtW4 F+I7wqU5KKoD6rF1sJSfbiU0RFoCIr7OIS50T0ID8wjefAmNHM7Gpfu8YJmIaUDuIy j7MXKxq0BuRqPNX+YvuE4VqajjUzNOS0sg7JJUsxZRhMROIdjFFR/FLqv+5/T7OFnp JO3lmkNrxf73w== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4KBJCX5M8Lz9rxb; Sun, 6 Mar 2022 11:45:44 +0100 (CET) Autocrypt: addr=philipk@posteo.net; prefer-encrypt=nopreference; keydata= mDMEYHHqUhYJKwYBBAHaRw8BAQdAp3GdmYJ6tm5McweY6dEvIYIiry+Oz9rU4MH6NHWK0Ee0QlBo aWxpcCBLYWx1ZGVyY2ljIChnZW5lcmF0ZWQgYnkgYXV0b2NyeXB0LmVsKSA8cGhpbGlwa0Bwb3N0 ZW8ubmV0PoiQBBMWCAA4FiEEDM2H44ZoPt9Ms0eHtVrAHPRh1FwFAmBx6lICGwMFCwkIBwIGFQoJ CAsCBBYCAwECHgECF4AACgkQtVrAHPRh1FyTkgEAjlbGPxFchvMbxzAES3r8QLuZgCxeAXunM9gh io0ePtUBALVhh9G6wIoZhl0gUCbQpoN/UJHI08Gm1qDob5zDxnIHuDgEYHHqUhIKKwYBBAGXVQEF AQEHQNcRB+MUimTMqoxxMMUERpOR+Q4b1KgncDZkhrO2ql1tAwEIB4h4BBgWCAAgFiEEDM2H44Zo Pt9Ms0eHtVrAHPRh1FwFAmBx6lICGwwACgkQtVrAHPRh1Fw1JwD/Qo7kvtib8jy7puyWrSv0MeTS g8qIxgoRWJE/KKdkCLEA/jb9b9/g8nnX+UcwHf/4VfKsjExlnND3FrBviXUW6NcB In-Reply-To: ("Mattias =?UTF-8?Q?Engdeg=C3=A5rd?="'s message of "Sun, 6 Mar 2022 10:56:26 +0100") 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" Xref: news.gmane.io gmane.emacs.bugs:228057 Archived-At: Mattias Engdeg=C3=A5rd writes: >> I haven't seen the function being used anywhere up until now (which > doesn't have to mean anything), but considering that this is a > relatively niche edge-case I would say that the bug should either be > solved now or never. > > Let's solve it now then. I'm to blame, patch attached. A related question is if something like (should (equal (color-values-from-color-spec "rgbi:0/0/0x0") nil)) should be accepted or not. From looking at xfaces-tests.el I was surprised to see that the exponential notation was intentional, but there was no comment or test on the un-lispy 0x... notation that strtod allows. > From 0433c23ce12ea24bcb4de93b92b92070cf257310 Mon Sep 17 00:00:00 2001 > From: =3D?UTF-8?q?Mattias=3D20Engdeg=3DC3=3DA5rd?=3D > Date: Sun, 6 Mar 2022 10:50:27 +0100 > Subject: [PATCH] Don't accept leading whitespace in rgbi: colour specs > > `color-values-from-color-spec` (new in Emacs 28) erroneously accepted > leading whitespace in rgbi: components. > > Reported by Philip Kaludercic. > > * src/xfaces.c (parse_float_color_comp): Disallow leading whitespace. > * test/src/xfaces-tests.el > (xfaces-internal-color-values-from-color-spec): Add test case. > --- > src/xfaces.c | 4 ++++ > test/src/xfaces-tests.el | 3 ++- > 2 files changed, 6 insertions(+), 1 deletion(-) > > diff --git a/src/xfaces.c b/src/xfaces.c > index 8100bdb157..7fbc667dfd 100644 > --- a/src/xfaces.c > +++ b/src/xfaces.c > @@ -888,6 +888,10 @@ parse_hex_color_comp (const char *s, const char *e, = unsigned short *dst) > static double > parse_float_color_comp (const char *s, const char *e) > { > + if (s >=3D e || > + !(*s =3D=3D '0' || *s =3D=3D '1' || *s =3D=3D '.' || *s =3D=3D '+'= || *s =3D=3D '-')) > + /* No leading whitespace permitted. */ > + return -1; > char *end; > double x =3D strtod (s, &end); > return (end =3D=3D e && x >=3D 0 && x <=3D 1) ? x : -1; > diff --git a/test/src/xfaces-tests.el b/test/src/xfaces-tests.el > index 31c0f021b2..1175874144 100644 > --- a/test/src/xfaces-tests.el > +++ b/test/src/xfaces-tests.el > @@ -47,7 +47,8 @@ xfaces-internal-color-values-from-color-spec > '(0 32768 6554))) > (should (equal (color-values-from-color-spec "rgbi:1e-3/1.0e-2/1e0") > '(66 655 65535))) > - (should (equal (color-values-from-color-spec "rgbi:0/0.5/10") nil))) > + (should (equal (color-values-from-color-spec "rgbi:0/0.5/10") nil)) > + (should (equal (color-values-from-color-spec "rgbi:0/0/ 0") nil))) >=20=20 > (provide 'xfaces-tests) --=20 Philip Kaludercic