Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 88e1e91

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 4e2477b commit 88e1e91

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/backend/parser/scan.l

+7
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)