From 2990aa45d188b1d9814c89dd44658f068eb37e83 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 25 Jul 2017 17:37:57 +0200 Subject: ash: sync up with dash with respect to redirection escaping We fixed the problem differently than they. Let's not deviate. Upstream commit: Date: Thu, 27 May 2010 20:07:29 +1000 [EXPAND] Fix corruption of redirections with byte 0x81 In other ash variants, a partial implementation of ksh-like cmd >file* adds and removes CTLESC bytes ('\x81') in redirection filenames, preserving 8-bit transparency. Long ago, dash removed the code to add the CTLESC bytes, but not the code to remove them, causing corruption of filenames containing CTLESC. This commit removes the code to remove the CTLESC bytes. The CTLESC byte occurs frequently in UTF-8 encoded non-Latin text. This bug has been reported various times to Ubuntu and Debian (e.g. Launchpad Ubuntu #422298). This patch is the same as the one submitted by Alexander Korolkov in Ubuntu #422298. Signed-off-by: Jilles Tjoelker Signed-off-by: Herbert Xu function old new delta changepath 194 192 -2 expandarg 1000 984 -16 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-18) Total: -18 bytes Signed-off-by: Denys Vlasenko --- shell/ash.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/shell/ash.c b/shell/ash.c index 72ceba7..c353834 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -5711,7 +5711,7 @@ ash_arith(const char *s) #define RMESCAPE_SLASH 0x20 /* Stop globbing after slash */ /* Add CTLESC when necessary. */ -#define QUOTES_ESC (EXP_FULL | EXP_CASE | EXP_QPAT | EXP_REDIR) +#define QUOTES_ESC (EXP_FULL | EXP_CASE | EXP_QPAT) /* Do not skip NUL characters. */ #define QUOTES_KEEPNUL EXP_TILDE @@ -7608,10 +7608,6 @@ expandarg(union node *arg, struct arglist *arglist, int flag) exparg.lastp = &exparg.list; expandmeta(exparg.list /*, flag*/); } else { - if (flag & EXP_REDIR) { /*XXX - for now, just remove escapes */ - rmescapes(p, 0); - TRACE(("expandarg: rmescapes:'%s'\n", p)); - } sp = stzalloc(sizeof(*sp)); sp->text = p; *exparg.lastp = sp; -- cgit v1.1