提交 f587d3bc 编写于 作者: S sherman

6635133: Exception thrown when using a Unicode escape

Summary: Update regex engine to handle unicode escape correctly in character class
Reviewed-by: okutsu
上级 1b87b506
......@@ -2844,7 +2844,15 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) {
/**
* Utility method for parsing unicode escape sequences.
*/
private int u() {
private int cursor() {
return cursor;
}
private void setcursor(int pos) {
cursor = pos;
}
private int uxxxx() {
int n = 0;
for (int i = 0; i < 4; i++) {
int ch = read();
......@@ -2856,6 +2864,20 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) {
return n;
}
private int u() {
int n = uxxxx();
if (Character.isHighSurrogate((char)n)) {
int cur = cursor();
if (read() == '\\' && read() == 'u') {
int n2 = uxxxx();
if (Character.isLowSurrogate((char)n2))
return Character.toCodePoint((char)n, (char)n2);
}
setcursor(cur);
}
return n;
}
//
// Utility methods for code point support
//
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册