Description
The regular expression for octal escape sequences matches too much (0\d{0,3}
instead of 0[0-7]{0,3}
, although that is still too much), replaces a \0
prefix with just \
, and then if the unquoting of the escape sequence fails it inserts the manipulated match.
Meaning this value: "\079"
Gives this string: "\\79"
While it should give: "\x079"
(bytes: [ 0x07, 0x39 ]
)
I.e. this are two bugs. Using the manipulated match when unquoting fails and matching too much and thus failing valid octal escape sequences.
Edit: Also through trail and error I found out that strconv.UnquoteChar()
wants octal escape sequences to be exactly 3 octal numbers long, meaning the regular expression should actually be 0[0-7]{3}
, or the match needs to be 0
-padded to 3 characters long.
Further the regular expression also matches \c
, which I can't find in the Go spec.
Line 19 in 9d0d133
Line 225 in 9d0d133