Description

When you upload Lua scripts to Redis escaped hex characters don't appear to be being uploaded correctly - the backslash disappears

Reproduction

Create a Lua script called test.lua with the contents

-- defines ch as the string containing a "#" character, change to one you want - all seem to be affected
local ch = "\x23" 
return ch

Upload with

cat test.lua | redis-cli -x script load

Then start up redis-cli and run

evalsha b4aff437dc11a0f061b0d9ff413e686e622bc43a 0

(hopefully I typed in the right hash - use the one output for you if different)

The output will be "x23"

Expected behaviour

I believe the output should be "#" (or possibly "\x23" if not a printable character. I first encountered this bug when trying to use \x1e)

Additional Information

Using stock Redis in current Ubuntu LTS. Redis version is 5.0.7-2,

Comment From: PartialDragster

In fact eval seems to be affected as well

> eval "return \"\\x23\"" 0
"x23"

Comment From: PartialDragster

Actually doing some more reading I see hex escape sequences were introduced in Lua 5.2 and IIRC Redis uses Lua 5.1. If true this ticket can probably be closed, sorry about that.