View Single Post
01/31/21, 12:23 PM   #1
Shinni
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 167
[open] bug in lua string escape

There is a bug when reading escaped strings.
Any string containing the byte sequence 5C 30 B2 is unable to be loaded by the game.
For example when a string contains the byte sequence 00 B2 and is stored in the saved variables, eso stores the string in escaped form and 00 B2 is stored/escaped as 5C 30 B2 (i.e. the 0 byte becomes \0). When the game then tries to read this escaped string, it throws the error "escape sequence too large near '' ".

How to reproduce:
mySavedVarsTable.test = string.char(0,178) -- assign the string consisting of 00 B2
/reloadui -- the game now stores 5C 30 B2 (\0 in the saved variables file because 00 is escaped to 5C 30
You now get a lua error "escape sequence too large near '' "

edit: Besides of 5C 30 B2 this also when replacing B2 by B3 or B9.
B2 = ² (exponent 2)
B3 = ³ (exponent 3)
B9 = ¹ (exponent 1)
No other characters throw this error when preceded by \0 except for these three exponent characters.

edit2:
Since in lua one can escape characters via \decimal (eg \65 for A) I think your unescape algorithm tries to read \0² as a single character like \02 instead of two characters \0 and ².

edit3:
Actually, the issue is larger than that. The string 00 32 (0 byte followed by the character 2) is escaped to \02, i.e. \0 and 2.
However, when loading the string it is interpreted as a single character instead of two.

Last edited by Shinni : 01/31/21 at 12:43 PM.
  Reply With Quote