Skip to content

lexer: combine surrogate pair escapes in string literals - #476

Merged
StevenACoffman merged 1 commit into
vektah:masterfrom
Rohilalala:fix/surrogate-pair-escape
Sep 30, 2026
Merged

StevenACoffman merged 1 commit into
vektah:masterfrom
Rohilalala:fix/surrogate-pair-escape

Conversation

@Rohilalala

Copy link
Copy Markdown
Contributor

Fixes #468.

A string literal with a surrogate pair of \u escapes parsed as two U+FFFD:

before  "😀" -> "��"
after   "😀" -> "\U0001f600"   (same as the literal "😀")

A leading surrogate escape followed by a trailing surrogate escape is now decoded as one code point, as the spec's EscapedUnicode grammar and graphql-js do.

Not changed: a lone surrogate escape still becomes U+FFFD. The current spec makes it a parse error, which I left for a separate change. The new lexer cases pin the current behaviour.

I have:

  • Added tests covering the bug / feature
  • Updated any relevant documentation

"\uD83D\uDE00" parsed as two U+FFFD. A leading surrogate escape followed
by a trailing surrogate escape is now decoded as one code point, as the
spec's EscapedUnicode grammar and graphql-js do.

Fixes vektah#468
@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 87.492% (+0.02%) from 87.472% — Rohilalala:fix/surrogate-pair-escape into vektah:master

@StevenACoffman
StevenACoffman merged commit eaee109 into vektah:master Sep 30, 2026
6 checks passed
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 this pull request may close these issues.

A surrogate pair escape \uD83D\uDE00 in a string literal parses as two U+FFFD

3 participants