Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unicode escape codes in template literal strings are improperly sanitized #484

Closed
chemiclast opened this issue Mar 23, 2024 · 1 comment
Closed

Comments

@chemiclast
Copy link

When using unicode escape codes (\u{XXXX}) in template literal strings, the compiler escapes the curly braces when it shouldn't resulting in malformed escape sequences.

Example Source Code

const string_a = "\u{E000}";
const string_b = `\u{E000}`;

Expected Emit

local string_a = "\u{E000}"
local string_b = `\u{E000}`

Actual Emit

local string_a = "\u{E000}"
local string_b = `\u\{E000\}` -- throws!

Playground Link

@osyrisrblx osyrisrblx transferred this issue from roblox-ts/roblox-ts Jun 22, 2024
osyrisrblx added a commit that referenced this issue Jun 22, 2024
osyrisrblx added a commit that referenced this issue Jun 24, 2024
Fixes #458 and #484

## #458: Incorrect escaping for multi-line interpolated string literals

The issue was that the escape logic did not pick up Windows-style line
endings properly. For this we need to also check for `\r` followed by an
optional `\n`.

### Input
```ts
warn(`look I am
a multiline string`)
```

### Before
```luau
warn(`look I am
\
a multiline string`)
```

### After
```luau
warn(`look I am\
a multiline string`)
```

## #484: Incorrect escaping for unicode escape sequences in interpolated
string literals

### Input
```ts
const string_a = "\u{E000}";
const string_b = `\u{E000}`;
```

### Before
```luau
local string_a = "\u{E000}"
local string_b = `\u\{E000\}`
```

### After
```luau
local string_a = "\u{E000}"
local string_b = `\u{E000}`
```
osyrisrblx added a commit to roblox-ts/roblox-ts that referenced this issue Jun 24, 2024
@osyrisrblx
Copy link
Member

Fixed by #483

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants