From owner-svn-src-all@freebsd.org Tue Aug 7 14:47:40 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2E0DB1060DD7; Tue, 7 Aug 2018 14:47:40 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id CB27772730; Tue, 7 Aug 2018 14:47:39 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A7D7B1D382; Tue, 7 Aug 2018 14:47:39 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w77EldsJ069907; Tue, 7 Aug 2018 14:47:39 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w77Eld3I069906; Tue, 7 Aug 2018 14:47:39 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201808071447.w77Eld3I069906@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pfg set sender to pfg@FreeBSD.org using -f From: "Pedro F. Giffuni" Date: Tue, 7 Aug 2018 14:47:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r337419 - head/usr.bin/sed X-SVN-Group: head X-SVN-Commit-Author: pfg X-SVN-Commit-Paths: head/usr.bin/sed X-SVN-Commit-Revision: 337419 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 07 Aug 2018 14:47:40 -0000 Author: pfg Date: Tue Aug 7 14:47:39 2018 New Revision: 337419 URL: https://svnweb.freebsd.org/changeset/base/337419 Log: sed(1): partial fix for the case of the regex delimited with '['. We don't generally support the weird case of regular expresions delimited by an opening square bracket ('[') but POSIX says that inside bracket expressions, escaping is not possible and both '[' and '\' represent themselves. PR: 230198 (exp-run) Obtained from: OpenBSD Modified: head/usr.bin/sed/compile.c Modified: head/usr.bin/sed/compile.c ============================================================================== --- head/usr.bin/sed/compile.c Tue Aug 7 14:39:00 2018 (r337418) +++ head/usr.bin/sed/compile.c Tue Aug 7 14:47:39 2018 (r337419) @@ -393,11 +393,11 @@ compile_delimited(char *p, char *d, int is_tr) if ((d = compile_ccl(&p, d)) == NULL) errx(1, "%lu: %s: unbalanced brackets ([])", linenum, fname); continue; + } else if (*p == '\\' && p[1] == c) { + p++; } else if (*p == '\\' && p[1] == '[') { *d++ = *p++; - } else if (*p == '\\' && p[1] == c) - p++; - else if (*p == '\\' && p[1] == 'n') { + } else if (*p == '\\' && p[1] == 'n') { *d++ = '\n'; p += 2; continue;