From unknown Thu Aug 14 21:22:46 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#23635 <23635@debbugs.gnu.org> To: bug#23635 <23635@debbugs.gnu.org> Subject: Status: possible bug in \c escape handling Reply-To: bug#23635 <23635@debbugs.gnu.org> Date: Fri, 15 Aug 2025 04:22:46 +0000 retitle 23635 possible bug in \c escape handling reassign 23635 sed submitter 23635 Assaf Gordon severity 23635 normal thanks From debbugs-submit-bounces@debbugs.gnu.org Fri May 27 21:08:49 2016 Received: (at submit) by debbugs.gnu.org; 28 May 2016 01:08:49 +0000 Received: from localhost ([127.0.0.1]:43087 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b6Sk7-0006UP-D3 for submit@debbugs.gnu.org; Fri, 27 May 2016 21:08:49 -0400 Received: from eggs.gnu.org ([208.118.235.92]:51198) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b6Sk1-0006U6-74 for submit@debbugs.gnu.org; Fri, 27 May 2016 21:08:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b6Sju-0007UF-Ml for submit@debbugs.gnu.org; Fri, 27 May 2016 21:08:32 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM, T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:41750) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b6Sju-0007U8-J2 for submit@debbugs.gnu.org; Fri, 27 May 2016 21:08:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42168) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b6Sjr-0004bO-MR for bug-sed@gnu.org; Fri, 27 May 2016 21:08:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b6Sjn-0007T9-AP for bug-sed@gnu.org; Fri, 27 May 2016 21:08:26 -0400 Received: from mail-qk0-x244.google.com ([2607:f8b0:400d:c09::244]:36629) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b6Sjn-0007T3-3X for bug-sed@gnu.org; Fri, 27 May 2016 21:08:23 -0400 Received: by mail-qk0-x244.google.com with SMTP id l68so14772532qkf.3 for ; Fri, 27 May 2016 18:08:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:message-id:date:user-agent:mime-version; bh=Z2oAHZtKZmtTfAPOAAmq7uwQcwK0nio9uQnkDkIjiVo=; b=kfEFvZ7dKYbNst1HGEwZws9tCMLqryyKy8X97Yma+/Blz8wtZuEeQVi5v/fiYsLzBd 7NmJBd+fTMmoDW/xK/4vAw/hq2L9JY0VWEWHbkOvuDElKEi5wSJZDnyAJFnLd1Sh3maF IqphkjMv13ala3amylfYcoJmAdKUJZupxqV12NXbpcl8G313YEmYaCLnJhCv8kuyJBi3 9fQWL8OA1aAO3CRfxnWHOTWsj8o6lTavmrbXT6p+ZpE/MCdOqWY9ui64w8PlZm1mYZHE JOHHU7eD/BsgZWK2JKyAR4U3cHKXOX3he2f6PzZyJwse4D277pkHLzRzXO2KqMbpyoUd bOqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:message-id:date:user-agent :mime-version; bh=Z2oAHZtKZmtTfAPOAAmq7uwQcwK0nio9uQnkDkIjiVo=; b=IHOjFUheUXFCSuiqZ4Ijy1OK4J5egCnrsO7o3OkxjUAvJ8BsrtrgLGDpKYWBh/DWFP WEZnZEtG6Ezw8qF8NZNK5f644cNS17RCdBBQYPqkIwhQbgs8BVeVU+fdJuBusbqkxhQI WwLTwPHKIAmhE3aao41GJiegjGdTDgwNRfYON1w8cTy6HXXGW6Ju9TUJ6+zwsJw+8q0w F6e/VwpDc03WZCEY6Lhb8yCPfZbSVoLMQYWFr9zOZbbfyZ8e6BUXFoiBlJ+J36far6GW +RYRrrBGWlwf0j503dYQ9S4UQcPCk+Bk1V5IoelEKJ0lsSlST7PLubFQUewOBxRNEE4e y76g== X-Gm-Message-State: ALyK8tJ8wAS5w02Zn2Pyqixu8BFsGLZR17kImM2AWD4H76BLjA+0gUthmqiZxn/+3znpjw== X-Received: by 10.55.189.132 with SMTP id n126mr17223782qkf.117.1464397702747; Fri, 27 May 2016 18:08:22 -0700 (PDT) Received: from disco.erlich.nygenome.org ([69.74.14.178]) by smtp.googlemail.com with ESMTPSA id l35sm6137832qtd.10.2016.05.27.18.08.21 for (version=TLSv1/SSLv3 cipher=OTHER); Fri, 27 May 2016 18:08:21 -0700 (PDT) From: Assaf Gordon To: bug-sed@gnu.org Subject: possible bug in \c escape handling Message-ID: <5748EF85.5040202@gmail.com> Date: Fri, 27 May 2016 21:08:21 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.8.0 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------040609010904060301070306" X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 1.0 (+) This is a multi-part message in MIME format. --------------040609010904060301070306 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Hello, There might be a small bug in processing of GNU extension escape sequence "\c". When the character following "\c" is a backslash, the code consumes only one character, leading to inconsistent and incorrect output. Example: $ echo a | sed 's/./\c\\/' | od -c 0000000 034 \ \n 0000003 $ echo a | sed 's/./\c\d/' | od -c 0000000 034 d \n 0000003 but: $ echo a | sed 's/./\c\/' | od -c sed: -e expression #1, char 8: unterminated `s' command 0000000 Meaning there is no way to generate the character '\x034' alone with "\c". This is also somewhat inconsistent because it consumes a single backslash character (whereas everywhere else a single backslash is the escape character itself). For comparison, other characters behave as expected: $ sed 's/./\cA/' in | od -c 0000000 001 \n 0000002 $ sed 's/./\c[/' in | od -c 0000000 033 \n 0000002 $ sed 's/./\c]/' in | od -c 0000000 035 \n 0000002 As a side effect, it could also be confusing if the syntax allows 'recursive' escapes, such as "\c\x41", which might be argued to be '\c' of the following character, which should be first evaluated as \x61, resulting in "\cA". The attached patch fixes the problem with the following rules: 1. '\c\\' = Control-Backslash = ASCII 0x34. 2. Any other backslash combinations after "\c" are rejected, and sed aborts. Tests included. comments are welcomed. - assaf --------------040609010904060301070306 Content-Type: text/x-patch; name="0001-sed-reject-recursive-escaping-after-c.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0001-sed-reject-recursive-escaping-after-c.patch" >From 4512ebbaf753c32e2515f582382e3b3bb10fa781 Mon Sep 17 00:00:00 2001 From: Assaf Gordon Date: Fri, 27 May 2016 20:49:33 -0400 Subject: [PATCH] sed: reject recursive escaping after \c previously, sed 's/./\c\\/' or 's/./\c\d/' would produce incorrect results. Require two backslashes after \c to denote control sequence ^\ (ASCII 0x34), and reject recursive escaping (e.g. \c\x61). * sed/compile.c: (RECURSIVE_ESCAPE_C): new error message; (normalize_text): check for \c-backslash, reject recursive escaping. * testsuite/recursive-escape-c.sh: test new behaviour. * testsuite/Makefile.am: add new test. --- sed/compile.c | 11 +++++- testsuite/Makefile.am | 1 + testsuite/recursive-escape-c.sh | 83 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 testsuite/recursive-escape-c.sh diff --git a/sed/compile.c b/sed/compile.c index 270caaf..c039c24 100644 --- a/sed/compile.c +++ b/sed/compile.c @@ -138,7 +138,8 @@ static const char errors[] = "invalid usage of line address 0\0" "unknown command: `%c'\0" "incomplete command\0" - "\":\" lacks a label"; + "\":\" lacks a label\0" + "recursive escaping after \\c not allowed"; #define BAD_BANG (errors) #define BAD_COMMA (BAD_BANG + sizeof(N_("multiple `!'s"))) @@ -182,6 +183,8 @@ static const char errors[] = #define INCOMPLETE_CMD (UNKNOWN_CMD + sizeof(N_("unknown command: `%c'"))) #define COLON_LACKS_LABEL (INCOMPLETE_CMD \ + sizeof(N_("incomplete command"))) +#define RECURSIVE_ESCAPE_C (COLON_LACKS_LABEL \ + + sizeof(N_("\":\" lacks a label"))) /* #define END_ERRORS (COLON_LACKS_LABEL + sizeof(N_("\":\" lacks a label"))) */ static struct output *file_read = NULL; @@ -1466,6 +1469,12 @@ convert: if (++p < bufend) { *q++ = toupper((unsigned char) *p) ^ 0x40; + if (*p == '\\') + { + p++; + if (*p != '\\') + bad_prog(RECURSIVE_ESCAPE_C); + } p++; continue; } diff --git a/testsuite/Makefile.am b/testsuite/Makefile.am index b37e402..fd4f19e 100644 --- a/testsuite/Makefile.am +++ b/testsuite/Makefile.am @@ -12,6 +12,7 @@ T = \ in-place-hyphen.sh \ invalid-mb-seq-UMR.sh \ range-overlap.sh \ + recursive-escape-c.sh \ subst-mb-incomplete.sh \ temp-file-cleanup.sh diff --git a/testsuite/recursive-escape-c.sh b/testsuite/recursive-escape-c.sh new file mode 100644 index 0000000..4ce46dd --- /dev/null +++ b/testsuite/recursive-escape-c.sh @@ -0,0 +1,83 @@ +#!/bin/sh +# test \c escaping + +# Copyright (C) 2016 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +. "${srcdir=.}/init.sh"; path_prepend_ ../sed +print_ver_ sed + +fail=0 +unset POSIXLY_CORRECT +export LC_ALL=C + +# input file, any 6 lines would do, each a different test case +cat<in1 || framework_failure_ +a +a +a +a +a +a +EOF + +# input program +# (NOTE: every two-backslashes in the here-doc result +# in one backslash in the file) +cat<prog1 || framework_failure_ +1s/./\\cA/ +2s/./\\cB/ +3s/./\\c[/ +4s/./\\c]/ + +# '\c' at end-of-buffer, a backslash is pushed up +# on level of interpretation, and the '.' match is replaced +# with one backslash. +5s/./\\c/ + +# This would return incorrect results before 4.3, +# producing both \034 and another backslash. +6s/./\\c\\\\/ +EOF + +# expected output: +printf '\001\n\002\n\033\n\035\n\\\n\034\n' > exp1 || framework_failure_ + +# +# Run simple test cases +# +sed -f prog1 in1 > out1 || fail=1 +compare_ exp1 out1 || fail=1 + +# for easier troubleshooting, if users ever report errors +if test "$fail" -eq 1 ; then + od -tx1c prog1 + od -tx1c exp1 + od -tx1c out1 +fi + +# +# Test invalid usage +# +cat<exp-err || framework_failure_ +sed: -e expression #1, char 10: recursive escaping after \c not allowed +EOF + +# Before sed-4.3, this resulted in '\034d' . +# now it should be rejected. +returns_ 1 sed '1s/./\c\d/' in1 2>err || fail=1 +compare_ exp-err err || fail=1 + +Exit $fail +EOF -- 2.8.2 --------------040609010904060301070306-- From debbugs-submit-bounces@debbugs.gnu.org Sat May 28 18:06:52 2016 Received: (at 23635) by debbugs.gnu.org; 28 May 2016 22:06:52 +0000 Received: from localhost ([127.0.0.1]:45091 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b6mNg-0006XX-0M for submit@debbugs.gnu.org; Sat, 28 May 2016 18:06:52 -0400 Received: from mail-oi0-f42.google.com ([209.85.218.42]:35980) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b6mNf-0006XJ-65 for 23635@debbugs.gnu.org; Sat, 28 May 2016 18:06:51 -0400 Received: by mail-oi0-f42.google.com with SMTP id j1so222564994oih.3 for <23635@debbugs.gnu.org>; Sat, 28 May 2016 15:06:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=OKfUk392NnrZf6iOFoK4WwrChC5sHacj+FWHMwPVlQ8=; b=H2cl2tCOVCHc6vcJnB7aO3iPw91cSbEaH04aLDtU5tyjh/i7O8+g+o2ed7xI3U1L+p Fm9ovFZ/1VOSRxkmq+k4oNkDJTeG/WwKm3zK8+U3FyB9wxObvOQ5itJccncJTt7WnaP+ eVGCxZ+M6Ucn5bB/LuLNRLwtfEzWu8M32uc4GrvvPGpBgK2sKiruFmrIORas0XV7A2Sa CojMr2eVckul3toc729cGgIXVkudw8JBTB3pmCjG+Gd/7nWKB0598zaI1wAgokgBvyHn 3Uu9N2+8A1GMOnMT/uU6UjMahDdPSW450KctUgIRevVRfhwA0ktljyOIuM/s/027f/de RsWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=OKfUk392NnrZf6iOFoK4WwrChC5sHacj+FWHMwPVlQ8=; b=cGOXERacqtED6N2QKJtAGHn/Oja6juvZrdycCg8VjXo5z35zeo0wIV84Ddbr3pUYR5 QCNKx7Klxb8igVoxXQTmZA8eNh36qE7ToQ29ZCuZu5D6ZxX0b5s47512MNKGuAFSaQ9R 6ABHOvSjbmLz7EVFYscT9SkCJkCMKwllUQEngo5Nwsv5qQTpwGwcN8Xg7jChb3KWnik2 RV1LzTS3rYifMMCwk1G1Pqy3ryXRiA0f0YG1bYY4gc5/tRBU0Tpq/ym9kfrZYu5lcR7V jwRn293wF5R2s/IdkKDZqWvUvhzsduR2H4iHLb2FxIPR4sCeazugyne48U1S8TPOXKvP gAWg== X-Gm-Message-State: ALyK8tKbV9Mcm1b/WrcerQzNGee+A8gnf1RsI2xXP6IR2MW2AFpc+5x/Q/iXD/aG5dUC1mVhui9nNYzWAJ04vw== X-Received: by 10.157.11.236 with SMTP id 99mr12927516oth.103.1464473205245; Sat, 28 May 2016 15:06:45 -0700 (PDT) MIME-Version: 1.0 Received: by 10.202.74.151 with HTTP; Sat, 28 May 2016 15:06:25 -0700 (PDT) In-Reply-To: <5748EF85.5040202@gmail.com> References: <5748EF85.5040202@gmail.com> From: Jim Meyering Date: Sat, 28 May 2016 15:06:25 -0700 X-Google-Sender-Auth: 3h3r1BMOIyp3245ORgfc9BUCa4w Message-ID: Subject: Re: bug#23635: possible bug in \c escape handling To: Assaf Gordon Content-Type: text/plain; charset=UTF-8 X-Spam-Score: -0.5 (/) X-Debbugs-Envelope-To: 23635 Cc: 23635@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.5 (/) On Fri, May 27, 2016 at 6:08 PM, Assaf Gordon wrote: > Hello, > > There might be a small bug in processing of GNU extension escape sequence > "\c". > > When the character following "\c" is a backslash, the code consumes only one > character, leading to inconsistent and incorrect output. > Example: > > $ echo a | sed 's/./\c\\/' | od -c > 0000000 034 \ \n > 0000003 > $ echo a | sed 's/./\c\d/' | od -c > 0000000 034 d \n > 0000003 > > but: > > $ echo a | sed 's/./\c\/' | od -c > sed: -e expression #1, char 8: unterminated `s' command > 0000000 > > Meaning there is no way to generate the character '\x034' alone with "\c". > > This is also somewhat inconsistent because it consumes a single backslash > character > (whereas everywhere else a single backslash is the escape character itself). > > For comparison, other characters behave as expected: > > $ sed 's/./\cA/' in | od -c > 0000000 001 \n > 0000002 > $ sed 's/./\c[/' in | od -c > 0000000 033 \n > 0000002 > $ sed 's/./\c]/' in | od -c > 0000000 035 \n > 0000002 > > As a side effect, it could also be confusing if the syntax allows > 'recursive' escapes, > such as "\c\x41", which might be argued to be '\c' of the following > character, > which should be first evaluated as \x61, resulting in "\cA". > > The attached patch fixes the problem with the following rules: > 1. '\c\\' = Control-Backslash = ASCII 0x34. > 2. Any other backslash combinations after "\c" are rejected, and sed aborts. > > Tests included. comments are welcomed. Nice catch. I like the patch. So far, I can make only two suggestions: - add a NEWS entry, since this is a bug fix - I have a slight preference for the one-liner printf '%s\n' a a a a a a a ---- rather than your 7-line here-document to generate that same output in the test case. And a comment wording nit: +# Before sed-4.3, this resulted in '\034d' . +# now it should be rejected. I prefer to say e.g., # Before sed-4.3, this resulted in '\034d'. Now, it is rejected. Thank you! From debbugs-submit-bounces@debbugs.gnu.org Sat May 28 22:32:04 2016 Received: (at 23635) by debbugs.gnu.org; 29 May 2016 02:32:04 +0000 Received: from localhost ([127.0.0.1]:45182 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b6qWK-0005y9-Af for submit@debbugs.gnu.org; Sat, 28 May 2016 22:32:04 -0400 Received: from mail-qk0-f178.google.com ([209.85.220.178]:34628) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b6qWI-0005xc-Iw for 23635@debbugs.gnu.org; Sat, 28 May 2016 22:32:02 -0400 Received: by mail-qk0-f178.google.com with SMTP id y126so103405511qke.1 for <23635@debbugs.gnu.org>; Sat, 28 May 2016 19:32:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:subject:from:in-reply-to:date:cc:message-id:references :to; bh=/ELCD64EeW4yrvrAh85mZkuWrH7ljPqj7hBUPTnhFSs=; b=pNVJYREGi8q5Yw/yBBsulVmE8pzNhRNgcG6IgFHF7oj9qszTxI73W+sqxDBvqQdJH2 BjrnTvqIcl35AvwoiVD+PisnJSFgCD/c4bgCKd2XaZsJ1SQcpMGN3MNjEdg8YIwcO6Rl NVIARXtj3Bwi+2GCmR75A0tUGUCT1VK4gQKzOKeB1V39Q8ZVeBr6uwsqhMBYKnFWG+E4 ckvObt/LME6mqG5U6igmTEmm9d7ecADsm/Rs5BpSrYcW0ogS4V6W4U49nvvaVPkdfe8u rYqQ+/JCCawh2xeL6/pRhlu62wG2A1EeJMy7bP9wrztRF8qae7IfVD1a6CfhxhXyeWtG rfzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :message-id:references:to; bh=/ELCD64EeW4yrvrAh85mZkuWrH7ljPqj7hBUPTnhFSs=; b=Wi9uw+pctUoiKuZtDyUIhxPsIh1QxAS/rubD+h5Ntbzgt6mJXTfTKJvZkHZli2yeRo Ws3YjQ7yz8blSCyBeaV1QcAJ6JtVAmvIY5aRdqFPcc1mW45Dm/c+8oPYZeQ1eof3PF73 KziwHPCvgJUxNr9EG04CW6luG0BlCFGtCt7cTW/9KZplt1i+1y3EBVu1GCvIUwPOCxuk uipkOQW54GzRJ9oIVbMH5zdQ8UECHazlBAvr90HLqglb5acNsf0b32Xik2ov8P5Mpgpn 07vCeiZbvZ6X+mn3w7z7Bun3ziGoL4Fn7pugFoe0WJxn3SdAd5q9IILyo8TsuX0hT/vI v2dA== X-Gm-Message-State: ALyK8tLgXuiJuVJutkAg86ceV3aPsQwbgdKHu4WBIynmLi9jntXFdWEEC9VftK9SBXXHuQ== X-Received: by 10.55.116.69 with SMTP id p66mr20907767qkc.129.1464489116962; Sat, 28 May 2016 19:31:56 -0700 (PDT) Received: from ix.home (pool-100-38-105-55.nycmny.fios.verizon.net. [100.38.105.55]) by smtp.gmail.com with ESMTPSA id i92sm7493671qtb.45.2016.05.28.19.31.55 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 28 May 2016 19:31:56 -0700 (PDT) Content-Type: multipart/mixed; boundary="Apple-Mail=_C55C72A3-9866-4BB7-B298-014ADBA7AF78" Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2102\)) Subject: Re: bug#23635: possible bug in \c escape handling From: Assaf Gordon In-Reply-To: Date: Sat, 28 May 2016 22:31:54 -0400 Message-Id: References: <5748EF85.5040202@gmail.com> To: Jim Meyering X-Mailer: Apple Mail (2.2102) X-Spam-Score: 0.3 (/) X-Debbugs-Envelope-To: 23635 Cc: 23635@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.3 (/) --Apple-Mail=_C55C72A3-9866-4BB7-B298-014ADBA7AF78 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii Hello, Thank you for the review. Attached an improved version. Regarding when the bug was introduced (in the 'NEWS'), version 3.02 did = not support \c escapes, and version 4.0.6 had this bug (as does the = first git commit). I wrote: [bug introduced in the sed-4.0.* releases] Comments welcomed, - assaf =20 --Apple-Mail=_C55C72A3-9866-4BB7-B298-014ADBA7AF78 Content-Disposition: attachment; filename=0001-sed-reject-recursive-escaping-after-c.patch Content-Type: application/octet-stream; name="0001-sed-reject-recursive-escaping-after-c.patch" Content-Transfer-Encoding: quoted-printable =46rom=20ea063a9079a2559a6831068bf2df94c745090fbe=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20Assaf=20Gordon=20=0A= Date:=20Sat,=2028=20May=202016=2022:26:43=20-0400=0ASubject:=20[PATCH]=20= sed:=20reject=20recursive=20escaping=20after=20\c=0A=0Apreviously,=20sed=20= 's/./\c\\/'=20or=20's/./\c\d/'=20would=20produce=20incorrect=0Aresults.=20= Require=20two=20backslashes=20after=20\c=20to=20denote=20control=20= sequence=0A^\=20(ASCII=200x34),=20and=20reject=20recursive=20escaping=20= (e.g.=20\c\x61).=0A=0A*=20sed/compile.c:=20(RECURSIVE_ESCAPE_C):=20new=20= error=20message;=0A(normalize_text):=20check=20for=20\c-backslash,=20= reject=20recursive=20escaping.=0A*=20testsuite/recursive-escape-c.sh:=20= test=20new=20behaviour.=0A*=20testsuite/Makefile.am:=20add=20new=20test.=0A= *=20NEWS:=20mention=20bug=20fix.=0A---=0A=20NEWS=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20|=20=205=20+++=0A= =20sed/compile.c=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= |=2011=20+++++-=0A=20testsuite/Makefile.am=20=20=20=20=20=20=20=20=20=20=20= |=20=201=20+=0A=20testsuite/recursive-escape-c.sh=20|=2075=20= +++++++++++++++++++++++++++++++++++++++++=0A=204=20files=20changed,=2091=20= insertions(+),=201=20deletion(-)=0A=20create=20mode=20100644=20= testsuite/recursive-escape-c.sh=0A=0Adiff=20--git=20a/NEWS=20b/NEWS=0A= index=2045ae7ae..3a15946=20100644=0A---=20a/NEWS=0A+++=20b/NEWS=0A@@=20= -49,6=20+49,11=20@@=20GNU=20sed=20NEWS=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= -*-=20outline=20-*-=0A=20=20=20Now,=20sed=20copies=20such=20bytes=20into=20= the=20output,=20just=20as=20Perl=20does.=0A=20=20=20[bug=20introduced=20= in=20sed-4.1=20--=20it=20was=20also=20present=20prior=20to=204.0.6]=0A=20= =0A+=20=20sed=20no=20longer=20prints=20extraneous=20character=20when=20a=20= backslash=20follows=20\c.=0A+=20=20'\c\\'=20=20generates=20control=20= character=20^\=20(ASCII=200x1C).=0A+=20=20Other=20characters=20after=20= the=20second=20backslash=20are=20rejected=20(e.g.=20'\c\d').=0A+=20=20= [bug=20introduced=20in=20the=20sed-4.0.*=20releases]=0A+=0A=20**=20= Feature=20removal=0A=20=0A=20=20=20The=20"L"=20command=20(format=20a=20= paragraph=20like=20the=20fmt(1)=20command=20would)=0Adiff=20--git=20= a/sed/compile.c=20b/sed/compile.c=0Aindex=20270caaf..c039c24=20100644=0A= ---=20a/sed/compile.c=0A+++=20b/sed/compile.c=0A@@=20-138,7=20+138,8=20= @@=20static=20const=20char=20errors[]=20=3D=0A=20=20=20"invalid=20usage=20= of=20line=20address=200\0"=0A=20=20=20"unknown=20command:=20`%c'\0"=0A=20= =20=20"incomplete=20command\0"=0A-=20=20"\":\"=20lacks=20a=20label";=0A+=20= =20"\":\"=20lacks=20a=20label\0"=0A+=20=20"recursive=20escaping=20after=20= \\c=20not=20allowed";=0A=20=0A=20#define=20BAD_BANG=20(errors)=0A=20= #define=20BAD_COMMA=20(BAD_BANG=20+=20sizeof(N_("multiple=20`!'s")))=0A= @@=20-182,6=20+183,8=20@@=20static=20const=20char=20errors[]=20=3D=0A=20= #define=20INCOMPLETE_CMD=20(UNKNOWN_CMD=20+=20sizeof(N_("unknown=20= command:=20`%c'")))=0A=20#define=20COLON_LACKS_LABEL=20(INCOMPLETE_CMD=20= \=0A=20=20=20+=20sizeof(N_("incomplete=20command")))=0A+#define=20= RECURSIVE_ESCAPE_C=20(COLON_LACKS_LABEL=20\=0A+=20=20+=20= sizeof(N_("\":\"=20lacks=20a=20label")))=0A=20/*=20#define=20END_ERRORS=20= (COLON_LACKS_LABEL=20+=20sizeof(N_("\":\"=20lacks=20a=20label")))=20*/=0A= =20=0A=20static=20struct=20output=20*file_read=20=3D=20NULL;=0A@@=20= -1466,6=20+1469,12=20@@=20convert:=0A=20=20=20=20=20=20=20=20=20=20=20=20= =20if=20(++p=20<=20bufend)=0A=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= {=0A=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20*q++=20=3D=20= toupper((unsigned=20char)=20*p)=20^=200x40;=0A+=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20if=20(*p=20=3D=3D=20'\\')=0A+=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20{=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20p++;=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20if=20(*p=20!=3D=20'\\')=0A+=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20bad_prog(RECURSIVE_ESCAPE_C);=0A+=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20}=0A=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20p++;=0A=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20continue;=0A=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20}=0A= diff=20--git=20a/testsuite/Makefile.am=20b/testsuite/Makefile.am=0Aindex=20= b37e402..fd4f19e=20100644=0A---=20a/testsuite/Makefile.am=0A+++=20= b/testsuite/Makefile.am=0A@@=20-12,6=20+12,7=20@@=20T=20=3D=09=09=09=09\=0A= =20=20=20in-place-hyphen.sh=09=09\=0A=20=20=20invalid-mb-seq-UMR.sh=09=09= \=0A=20=20=20range-overlap.sh=09=09\=0A+=20=20recursive-escape-c.sh=09=09= \=0A=20=20=20subst-mb-incomplete.sh=09\=0A=20=20=20temp-file-cleanup.sh=0A= =20=0Adiff=20--git=20a/testsuite/recursive-escape-c.sh=20= b/testsuite/recursive-escape-c.sh=0Anew=20file=20mode=20100644=0Aindex=20= 0000000..cea9c06=0A---=20/dev/null=0A+++=20= b/testsuite/recursive-escape-c.sh=0A@@=20-0,0=20+1,75=20@@=0A+#!/bin/sh=0A= +#=20test=20\c=20escaping=0A+=0A+#=20Copyright=20(C)=202016=20Free=20= Software=20Foundation,=20Inc.=0A+=0A+#=20This=20program=20is=20free=20= software:=20you=20can=20redistribute=20it=20and/or=20modify=0A+#=20it=20= under=20the=20terms=20of=20the=20GNU=20General=20Public=20License=20as=20= published=20by=0A+#=20the=20Free=20Software=20Foundation,=20either=20= version=203=20of=20the=20License,=20or=0A+#=20(at=20your=20option)=20any=20= later=20version.=0A+=0A+#=20This=20program=20is=20distributed=20in=20the=20= hope=20that=20it=20will=20be=20useful,=0A+#=20but=20WITHOUT=20ANY=20= WARRANTY;=20without=20even=20the=20implied=20warranty=20of=0A+#=20= MERCHANTABILITY=20or=20FITNESS=20FOR=20A=20PARTICULAR=20PURPOSE.=20=20= See=20the=0A+#=20GNU=20General=20Public=20License=20for=20more=20= details.=0A+=0A+#=20You=20should=20have=20received=20a=20copy=20of=20the=20= GNU=20General=20Public=20License=0A+#=20along=20with=20this=20program.=20= =20If=20not,=20see=20.=0A+.=20= "${srcdir=3D.}/init.sh";=20path_prepend_=20../sed=0A+print_ver_=20sed=0A= +=0A+fail=3D0=0A+unset=20POSIXLY_CORRECT=0A+export=20LC_ALL=3DC=0A+=0A+#=20= input=20file,=20any=206=20lines=20would=20do,=20each=20a=20different=20= test=20case=0A+printf=20"%s\n"=20a=20a=20a=20a=20a=20a=20>in1=20||=20= framework_failure_=0A+=0A+#=20input=20program=0A+#=20(NOTE:=20every=20= two-backslashes=20in=20the=20here-doc=20result=0A+#=20=20in=20one=20= backslash=20in=20the=20file)=0A+cat<prog1=20||=20framework_failure_=0A= +1s/./\\cA/=0A+2s/./\\cB/=0A+3s/./\\c[/=0A+4s/./\\c]/=0A+=0A+#=20'\c'=20= at=20end-of-buffer,=20a=20backslash=20is=20pushed=20up=0A+#=20on=20level=20= of=20interpretation,=20and=20the=20'.'=20match=20is=20replaced=0A+#=20= with=20one=20backslash.=0A+5s/./\\c/=0A+=0A+#=20This=20would=20return=20= incorrect=20results=20before=204.3,=0A+#=20producing=20both=20\034=20and=20= another=20backslash.=0A+6s/./\\c\\\\/=0A+EOF=0A+=0A+#=20expected=20= output:=0A+printf=20'\001\n\002\n\033\n\035\n\\\n\034\n'=20>=20exp1=20||=20= framework_failure_=0A+=0A+#=0A+#=20Run=20simple=20test=20cases=0A+#=0A= +sed=20-f=20prog1=20in1=20>=20out1=20||=20fail=3D1=0A+compare_=20exp1=20= out1=20||=20fail=3D1=0A+=0A+#=20for=20easier=20troubleshooting,=20if=20= users=20ever=20report=20errors=0A+if=20test=20"$fail"=20-eq=201=20;=20= then=0A+=20=20=20=20od=20-tx1c=20prog1=0A+=20=20=20=20od=20-tx1c=20exp1=0A= +=20=20=20=20od=20-tx1c=20out1=0A+fi=0A+=0A+#=0A+#=20Test=20invalid=20= usage=0A+#=0A+cat<exp-err=20||=20framework_failure_=0A+sed:=20-e=20= expression=20#1,=20char=2010:=20recursive=20escaping=20after=20\c=20not=20= allowed=0A+EOF=0A+=0A+#=20Before=20sed-4.3,=20this=20resulted=20in=20= '\034d'.=20Now,=20it=20is=20rejected.=0A+returns_=201=20sed=20= '1s/./\c\d/'=20in1=202>err=20||=20fail=3D1=0A+compare_=20exp-err=20err=20= ||=20fail=3D1=0A+=0A+Exit=20$fail=0A+EOF=0A--=20=0A2.7.0=0A=0A= --Apple-Mail=_C55C72A3-9866-4BB7-B298-014ADBA7AF78-- From debbugs-submit-bounces@debbugs.gnu.org Sat May 28 23:40:52 2016 Received: (at 23635) by debbugs.gnu.org; 29 May 2016 03:40:52 +0000 Received: from localhost ([127.0.0.1]:45192 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b6rau-0007av-0O for submit@debbugs.gnu.org; Sat, 28 May 2016 23:40:52 -0400 Received: from mail-oi0-f42.google.com ([209.85.218.42]:34318) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b6rar-0007ah-Tc for 23635@debbugs.gnu.org; Sat, 28 May 2016 23:40:50 -0400 Received: by mail-oi0-f42.google.com with SMTP id b65so227828530oia.1 for <23635@debbugs.gnu.org>; Sat, 28 May 2016 20:40:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=IxI9nv3NtH2iZj/TIw97dtj6+3+7POcycjtivDIKyZg=; b=GAenKCDpX2TZ/7iOgXUiseGuQDW6xEkhlZAcLIAiLQS+FHLuPPUQ1/Dd9dgyflS34h OFGgwAh9pdjeRc63CZC2COCZIPfzgajwTqGOKTnyuu3/ipbGq/szYF5mSs4APZ3MqpWi IxcVh2nRcirKHeTxcjsbbYK4gWXJmuYFaQBuZESdCXqMkI8JlkjOLvx0SOvHNTqUrRy0 zdW+h+54Otr6kG/Z4+G7UvwC4xOKipIBxHuV9QHuFY8BF6mgIKI25+ceBUz+NwFmiUTR mmaaT6Us9sVoN9EuJJBFJKLpmSwziMgCfOfKYGoilsxsa42MqtwRpUWRzo7jIOjEXHiN 3jGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=IxI9nv3NtH2iZj/TIw97dtj6+3+7POcycjtivDIKyZg=; b=j3bSLZ/WMVraJE9nCm+GLjOPn0etheYdZEJscR6SkRR/LhKviTc7yU27Pr3kQtjDvt G2xUhXADcWuuZyYSmk7YK8C4h4nQEv/7IgCwYWYRtzVHYiLfkRobpnunArjHZqIQZIxv UIrKL560lkXRx5ow6+8ao7/yFo2xrQtrICmwx+7MjKMIE1sCnoEjZP641aD35u1EA+sC E00cs5FzMZTLFoaRrECAR3qi/imAi9huJT6egOlmApUnI3ZsAjQTXuUlKLrV7fTxEQS5 Z8hIRy8eJi+W1C8lBZPnKfqnBQE0GIVViEsUNwSz41tUcXvcU64hitUHW5W3p1tjFXko WjSQ== X-Gm-Message-State: ALyK8tJxomFSiyYLJ4mg3GKxXyWxKPR26tBG/pCRW8WLo/YXE6ipD/uCBj3t0nWsXN0gelJ1s77dc2OHu+DdPw== X-Received: by 10.202.212.19 with SMTP id l19mr14361409oig.182.1464493244401; Sat, 28 May 2016 20:40:44 -0700 (PDT) MIME-Version: 1.0 Received: by 10.202.74.151 with HTTP; Sat, 28 May 2016 20:40:24 -0700 (PDT) In-Reply-To: References: <5748EF85.5040202@gmail.com> From: Jim Meyering Date: Sat, 28 May 2016 20:40:24 -0700 X-Google-Sender-Auth: KgifCOAhcRgBks6UHwV1opKKnbI Message-ID: Subject: Re: bug#23635: possible bug in \c escape handling To: Assaf Gordon Content-Type: multipart/mixed; boundary=001a113d21229be5b00533f2e7f1 X-Spam-Score: -0.5 (/) X-Debbugs-Envelope-To: 23635 Cc: 23635@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.5 (/) --001a113d21229be5b00533f2e7f1 Content-Type: text/plain; charset=UTF-8 On Sat, May 28, 2016 at 7:31 PM, Assaf Gordon wrote: > Hello, > > Thank you for the review. > Attached an improved version. > > Regarding when the bug was introduced (in the 'NEWS'), version 3.02 did not support \c escapes, and version 4.0.6 had this bug (as does the first git commit). I wrote: > [bug introduced in the sed-4.0.* releases] Thanks for the quick update! One more thing I noticed is that you use here docs that interpolate. Just as I prefer to use single-quoted strings most of the time, e.g., to avoid having to backslash-escape every backslash, I prefer to use quoted here docs as in the attached. Also, I prefer to space-delimit operators like '<', '<<', and '>'. At least on one side. Also, I removed a stray "EOF" after the final "Exit..." line. Here's the proposed delta, on top of your patch: --001a113d21229be5b00533f2e7f1 Content-Type: text/x-patch; charset=US-ASCII; name="k.patch" Content-Disposition: attachment; filename="k.patch" Content-Transfer-Encoding: base64 X-Attachment-Id: f_ios1eoi71 ZGlmZiAtLWdpdCBhL3Rlc3RzdWl0ZS9yZWN1cnNpdmUtZXNjYXBlLWMuc2ggYi90ZXN0c3VpdGUv cmVjdXJzaXZlLWVzY2FwZS1jLnNoCmluZGV4IGNlYTljMDYuLjk1ZDAwN2IgMTAwNjQ0Ci0tLSBh L3Rlc3RzdWl0ZS9yZWN1cnNpdmUtZXNjYXBlLWMuc2gKKysrIGIvdGVzdHN1aXRlL3JlY3Vyc2l2 ZS1lc2NhcGUtYy5zaApAQCAtMjYsMjIgKzI2LDIwIEBAIGV4cG9ydCBMQ19BTEw9QwogcHJpbnRm ICIlc1xuIiBhIGEgYSBhIGEgYSA+aW4xIHx8IGZyYW1ld29ya19mYWlsdXJlXwoKICMgaW5wdXQg cHJvZ3JhbQotIyAoTk9URTogZXZlcnkgdHdvLWJhY2tzbGFzaGVzIGluIHRoZSBoZXJlLWRvYyBy ZXN1bHQKLSMgIGluIG9uZSBiYWNrc2xhc2ggaW4gdGhlIGZpbGUpCi1jYXQ8PEVPRj5wcm9nMSB8 fCBmcmFtZXdvcmtfZmFpbHVyZV8KLTFzLy4vXFxjQS8KLTJzLy4vXFxjQi8KLTNzLy4vXFxjWy8K LTRzLy4vXFxjXS8KK2NhdCA8PCBcRU9GID4gcHJvZzEgfHwgZnJhbWV3b3JrX2ZhaWx1cmVfCisx cy8uL1xjQS8KKzJzLy4vXGNCLworM3MvLi9cY1svCis0cy8uL1xjXS8KCiAjICdcYycgYXQgZW5k LW9mLWJ1ZmZlciwgYSBiYWNrc2xhc2ggaXMgcHVzaGVkIHVwCiAjIG9uIGxldmVsIG9mIGludGVy cHJldGF0aW9uLCBhbmQgdGhlICcuJyBtYXRjaCBpcyByZXBsYWNlZAogIyB3aXRoIG9uZSBiYWNr c2xhc2guCi01cy8uL1xcYy8KKzVzLy4vXGMvCgogIyBUaGlzIHdvdWxkIHJldHVybiBpbmNvcnJl Y3QgcmVzdWx0cyBiZWZvcmUgNC4zLAogIyBwcm9kdWNpbmcgYm90aCBcMDM0IGFuZCBhbm90aGVy IGJhY2tzbGFzaC4KLTZzLy4vXFxjXFxcXC8KKzZzLy4vXGNcXC8KIEVPRgoKICMgZXhwZWN0ZWQg b3V0cHV0OgpAQCAtNjMsNyArNjEsNyBAQCBmaQogIwogIyBUZXN0IGludmFsaWQgdXNhZ2UKICMK LWNhdDw8RU9GPmV4cC1lcnIgfHwgZnJhbWV3b3JrX2ZhaWx1cmVfCitjYXQgPDwgXEVPRiA+IGV4 cC1lcnIgfHwgZnJhbWV3b3JrX2ZhaWx1cmVfCiBzZWQ6IC1lIGV4cHJlc3Npb24gIzEsIGNoYXIg MTA6IHJlY3Vyc2l2ZSBlc2NhcGluZyBhZnRlciBcYyBub3QgYWxsb3dlZAogRU9GCgpAQCAtNzIs NCArNzAsMyBAQCByZXR1cm5zXyAxIHNlZCAnMXMvLi9cY1xkLycgaW4xIDI+ZXJyIHx8IGZhaWw9 MQogY29tcGFyZV8gZXhwLWVyciBlcnIgfHwgZmFpbD0xCgogRXhpdCAkZmFpbAotRU9GCg== --001a113d21229be5b00533f2e7f1-- From debbugs-submit-bounces@debbugs.gnu.org Sun May 29 22:00:54 2016 Received: (at 23635-done) by debbugs.gnu.org; 30 May 2016 02:00:54 +0000 Received: from localhost ([127.0.0.1]:46744 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b7CVh-0002Zg-V9 for submit@debbugs.gnu.org; Sun, 29 May 2016 22:00:54 -0400 Received: from mail-oi0-f53.google.com ([209.85.218.53]:34649) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b7CVf-0002ZS-MU for 23635-done@debbugs.gnu.org; Sun, 29 May 2016 22:00:52 -0400 Received: by mail-oi0-f53.google.com with SMTP id b65so250502372oia.1 for <23635-done@debbugs.gnu.org>; Sun, 29 May 2016 19:00:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=ccfdtCBOwsYc/S9Duj0QWVPTWR3QAlZMQh4kKxa9uHg=; b=Y+OGBnzjdnDwsLwNm4rnstp5cFpQlQKaiHW/ZMPwPZ8Uy5KhwXeRPsF9zcXw+2iIkV eFHZtOGdjtKo3GhAFEIYG7Ep2U30/jvp2G896X6E7ZDHQaYPPQT0PSIWxr8y8y78lxnE ubCijTgJHKL3It5ll1kLkK6wCZ03p3RxCWHYEBXl88uIcJZUQFF6PvTiVsianh87CRih AilMSirUJItO0P/BdXj6clCTdf60lb08lAHggne3S2g+rl/GBIr5ms7hrTlR7sMmLGu0 TeNvsNr2VQfMo1eMOJ3gExSf0By58M01+HjVR3bmSQKoWCXeq0v3bENdqOXBusYAStnS amAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=ccfdtCBOwsYc/S9Duj0QWVPTWR3QAlZMQh4kKxa9uHg=; b=gjMRg3275IUGumxbtJpI6oGU1e4txEguHWY4lF4SOBeaKCKMNrTuT4khf07iwPFGJw mEu8YQ/qSTzSr70vpapJZEPCiYf3vLEO3zRKeBXKAsh1VJJYWsdUAh7vvKcDqvGUdaFu 3Iv2Re6YSAgewESBVkgxY2F5YAelYyVxjcPTZNVXIRYzxgB0TdapBdirEQPMrsLCcQft W6X9yAolIJ4umCegQkHboHFDin9PuNvmVn9OTakfkII+e8vOWDa8IYxLMlevYamf4zMl KsZkxXQBn+5GKsafDnsXv4PKKAs0vRGcuv/viOjyXYJeCLFdkXe1/+burqKsRmuDcuzn npCw== X-Gm-Message-State: ALyK8tKm/43iyWfg3yNd81euEjI2CWppuLfrjM5ylzuMrz0t+pQAd20lge5cctX8FqcMwYnGZciHX9ZHahj3OA== X-Received: by 10.202.69.212 with SMTP id s203mr9784562oia.45.1464573645771; Sun, 29 May 2016 19:00:45 -0700 (PDT) MIME-Version: 1.0 Received: by 10.202.74.151 with HTTP; Sun, 29 May 2016 19:00:25 -0700 (PDT) In-Reply-To: References: <5748EF85.5040202@gmail.com> From: Jim Meyering Date: Sun, 29 May 2016 19:00:25 -0700 X-Google-Sender-Auth: fLL4_8F2HZYwCcR-NM8ZEbpM5K8 Message-ID: Subject: Re: bug#23635: possible bug in \c escape handling To: Assaf Gordon Content-Type: text/plain; charset=UTF-8 X-Spam-Score: -0.5 (/) X-Debbugs-Envelope-To: 23635-done Cc: 23635-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.5 (/) On Sat, May 28, 2016 at 8:40 PM, Jim Meyering wrote: > On Sat, May 28, 2016 at 7:31 PM, Assaf Gordon wrote: >> Hello, >> >> Thank you for the review. >> Attached an improved version. >> >> Regarding when the bug was introduced (in the 'NEWS'), version 3.02 did not support \c escapes, and version 4.0.6 had this bug (as does the first git commit). I wrote: >> [bug introduced in the sed-4.0.* releases] > > Thanks for the quick update! > One more thing I noticed is that you use here docs > that interpolate. Just as I prefer to use single-quoted strings > most of the time, e.g., to avoid having to backslash-escape > every backslash, I prefer to use quoted here docs as in the > attached. Also, I prefer to space-delimit operators like '<', '<<', and '>'. > At least on one side. > > Also, I removed a stray "EOF" after the final "Exit..." line. > > Here's the proposed delta, on top of your patch: I've pushed your patch amended with that change, and tweaked the log message to have these lines: capitalized first word of each sentence and added the (T) and (Bug fixes) qualifiers: * sed/compile.c: (RECURSIVE_ESCAPE_C): New error message. (normalize_text): Check for \c-backslash, reject recursive escaping. * testsuite/recursive-escape-c.sh: New file. Test new behaviour. * testsuite/Makefile.am (T): Add new test. * NEWS (Bug fixes): Mention it. Thanks again. As I write this, I realized that I should have referenced the bug report URL in the commit log. Oh well. From debbugs-submit-bounces@debbugs.gnu.org Mon May 30 01:30:53 2016 Received: (at 23635-done) by debbugs.gnu.org; 30 May 2016 05:30:53 +0000 Received: from localhost ([127.0.0.1]:46796 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b7Fmv-0007VF-83 for submit@debbugs.gnu.org; Mon, 30 May 2016 01:30:53 -0400 Received: from mail-qk0-f173.google.com ([209.85.220.173]:32844) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b7Fms-0007V1-U7 for 23635-done@debbugs.gnu.org; Mon, 30 May 2016 01:30:51 -0400 Received: by mail-qk0-f173.google.com with SMTP id n63so116005245qkf.0 for <23635-done@debbugs.gnu.org>; Sun, 29 May 2016 22:30:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=42TWstXQkGsuf1RRgu98aFzyGu+g2zQ7LRqRshndN8s=; b=B0The+WF+PZK++D1JQpYXp+IN96E72A3kkis/+j3+I3LhanwHX+06bSFUkfqdfeRqB q0+05f6+aiPB2ICXh5DR0gyit9r1o22A2KTHcjkzBtEjYMAU0R8qYsY2PJNzAgMIH3XX VBAXzs6UQ76lVv6dfnWqM+CYXLIPT78KkdPbJr+w7iZHPkvsCWFoqlFDiT75StFTgKdw h9sfyC/iiGVAmxmvzXcSeIPqtqGKdNKTs7w9mJy9QKWppA5vWa26zfkZUMyOe/SGdrMV JXzf29/wuDAJhxAV+bQ+ShoesRQTTwGlczgjSWKu6ayLvwF84TMLE7URBTzh9Eiw9NcJ sxUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=42TWstXQkGsuf1RRgu98aFzyGu+g2zQ7LRqRshndN8s=; b=fI6uUkI6ZnBv9SB3WnU2Qjpohu6ioM4hqXsD3PhqU6tGnQCMPjNYR71BOGjf31Pyv+ fr5fuDTuoMYPJXN3tLVpAUhpaMOcll4qL/m6oU5gEqwMewk4dQRadVNLblQg0qOQnAMQ 3ivAKQ+TZ3FmvZWBFv5KjxOiNNQOtkAY3FKMozv1gpvmZ3VTIH+OnV6MYASpsU8uRxsw HxeIZdmeT0J7hm14G+CpiKjJrTTuw6J/OVbK8lSv1QbvbACX12CWkELcuVgGKGJi7T4V T/vq0UjL5hnsliDvbPwezJkbm/41TrS6/7fx7D4OvyP7+qr2gjk+gdo+vh8fLQoWL663 lMVw== X-Gm-Message-State: ALyK8tJt/DA5V1Yqdv6X0Bqs5yaM427dffzk4+TEKd5gdOdfJpJleH2NP6elUSOI4f4OjQ== X-Received: by 10.55.93.68 with SMTP id r65mr25760097qkb.174.1464586245265; Sun, 29 May 2016 22:30:45 -0700 (PDT) Received: from ix.home (pool-100-38-105-55.nycmny.fios.verizon.net. [100.38.105.55]) by smtp.gmail.com with ESMTPSA id 1sm9008116qkl.20.2016.05.29.22.30.44 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 29 May 2016 22:30:44 -0700 (PDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2102\)) Subject: Re: bug#23635: possible bug in \c escape handling From: Assaf Gordon In-Reply-To: Date: Mon, 30 May 2016 01:30:42 -0400 Content-Transfer-Encoding: 7bit Message-Id: <5D87B979-02CB-4EF6-A51A-D6D7D09C1DAF@gmail.com> References: <5748EF85.5040202@gmail.com> To: Jim Meyering X-Mailer: Apple Mail (2.2102) X-Spam-Score: 0.3 (/) X-Debbugs-Envelope-To: 23635-done Cc: 23635-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.3 (/) > I've pushed your patch amended with that change, and tweaked the log > message to have these lines: capitalized first word of each sentence > and added the (T) and (Bug fixes) qualifiers: > Thank you! From unknown Thu Aug 14 21:22:46 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Mon, 27 Jun 2016 11:24:03 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator