Skip to content

Commit a8ae123

Browse files
committed
Fix detection of unfinished Unicode surrogate pair at end of string.
The U&'...' and U&"..." syntaxes silently discarded a surrogate pair start (that is, a code between U+D800 and U+DBFF) if it occurred at the very end of the string. This seems like an obvious oversight, since we throw an error for every other invalid combination of surrogate characters, including the very same situation in E'...' syntax. This has been wrong since the pair processing was added (in 9.0), so back-patch to all supported branches. Discussion: https://postgr.es/m/19113.1482337898@sss.pgh.pa.us
1 parent 89fcea1 commit a8ae123

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/backend/parser/scan.l

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1435,6 +1435,13 @@ litbuf_udeescape(unsigned char escape, core_yyscan_t yyscanner)
14351435
}
14361436
}
14371437

1438+
/* unfinished surrogate pair? */
1439+
if (pair_first)
1440+
{
1441+
ADVANCE_YYLLOC(in - litbuf + 3); /* 3 for U&" */
1442+
yyerror("invalid Unicode surrogate pair");
1443+
}
1444+
14381445
*out = '\0';
14391446

14401447
/*

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy