From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22829 invoked by alias); 18 Dec 2014 19:29:35 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 34006 Received: (qmail 29956 invoked from network); 18 Dec 2014 19:29:24 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 X-Originating-IP: [86.6.25.230] X-Spam: 0 X-Authority: v=2.1 cv=Ku/D2AmN c=1 sm=1 tr=0 a=c0CwWhpM9oUd/BnC3z6Gzg==:117 a=c0CwWhpM9oUd/BnC3z6Gzg==:17 a=NLZqzBF-AAAA:8 a=IkcTkHD0fZMA:10 a=vaJtXVxTAAAA:8 a=nvyFQY6gAErfbIUrOMUA:9 a=QEXdDO2ut3YA:10 Date: Thu, 18 Dec 2014 19:29:17 +0000 From: Peter Stephenson To: zsh-workers Subject: Re: [BUG] Unicode variables can be exported and are exported metafied Message-ID: <20141218192917.4df5324b@pws-pc.ntlworld.com> In-Reply-To: <1054131418926765@web2o.yandex.ru> References: <1054131418926765@web2o.yandex.ru> X-Mailer: Claws Mail 3.8.0 (GTK+ 2.24.7; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Thu, 18 Dec 2014 21:19:25 +0300 ZyX wrote:=20 > You see here that variable named `=D1=83=D1=81` can be exported (not sure > whether it is a bug or not), I *think* that's a "don't do that unless you actually need to..." but feel free to present evidence otherwise. > but its 0x83 byte which is the last byte of the first unicode > codepoint that forms the variable name represented as UTF-8 is using > zsh `Meta` escape in the `env` output (which clearly is a bug assuming > the fact that unicode variable is exported is not). Yes, indeed. diff --git a/Src/params.c b/Src/params.c index 79088d1..b87598a 100644 --- a/Src/params.c +++ b/Src/params.c @@ -4357,7 +4357,18 @@ arrfixenv(char *s, char **t) int zputenv(char *str) { + char *ptr; DPUTS(!str, "Attempt to put null string into environment."); + /* + * The environment uses NULL-terminated strings, so just + * unmetafy and ignore the length. + */ + for (ptr =3D str; *ptr && *ptr !=3D Meta; ptr++) + ; + if (*ptr =3D=3D Meta) { + str =3D dupstring(str); + unmetafy(str, NULL); + } #ifdef USE_SET_UNSET_ENV /* * If we are using unsetenv() to remove values from the @@ -4366,7 +4377,6 @@ zputenv(char *str) * Unfortunately this is a slightly different interface * from what zputenv() assumes. */ - char *ptr; int ret; =20 for (ptr =3D str; *ptr && *ptr !=3D '=3D'; ptr++) pws