8230829: Matcher matches a surrogate pair that crosses border of the region
Reviewed-by: naoto
This commit is contained in:
parent
e8ee2800f5
commit
5e7e0e7bbe
@ -3931,12 +3931,14 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) {
|
|||||||
boolean match(Matcher matcher, int i, CharSequence seq) {
|
boolean match(Matcher matcher, int i, CharSequence seq) {
|
||||||
if (i < matcher.to) {
|
if (i < matcher.to) {
|
||||||
int ch = Character.codePointAt(seq, i);
|
int ch = Character.codePointAt(seq, i);
|
||||||
return predicate.is(ch) &&
|
i += Character.charCount(ch);
|
||||||
next.match(matcher, i + Character.charCount(ch), seq);
|
if (i <= matcher.to) {
|
||||||
} else {
|
return predicate.is(ch) &&
|
||||||
matcher.hitEnd = true;
|
next.match(matcher, i, seq);
|
||||||
return false;
|
}
|
||||||
}
|
}
|
||||||
|
matcher.hitEnd = true;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
boolean study(TreeInfo info) {
|
boolean study(TreeInfo info) {
|
||||||
info.minLength++;
|
info.minLength++;
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
* 8027645 8035076 8039124 8035975 8074678 6854417 8143854 8147531 7071819
|
* 8027645 8035076 8039124 8035975 8074678 6854417 8143854 8147531 7071819
|
||||||
* 8151481 4867170 7080302 6728861 6995635 6736245 4916384 6328855 6192895
|
* 8151481 4867170 7080302 6728861 6995635 6736245 4916384 6328855 6192895
|
||||||
* 6345469 6988218 6693451 7006761 8140212 8143282 8158482 8176029 8184706
|
* 6345469 6988218 6693451 7006761 8140212 8143282 8158482 8176029 8184706
|
||||||
* 8194667 8197462 8184692 8221431 8224789 8228352
|
* 8194667 8197462 8184692 8221431 8224789 8228352 8230829
|
||||||
*
|
*
|
||||||
* @library /test/lib
|
* @library /test/lib
|
||||||
* @library /lib/testlibrary/java/lang
|
* @library /lib/testlibrary/java/lang
|
||||||
@ -1070,6 +1070,22 @@ public class RegExTest {
|
|||||||
matcher.useAnchoringBounds(false);
|
matcher.useAnchoringBounds(false);
|
||||||
if (matcher.find())
|
if (matcher.find())
|
||||||
failCount++;
|
failCount++;
|
||||||
|
|
||||||
|
// JDK-8230829
|
||||||
|
pattern = Pattern.compile("\\ud800\\udc61");
|
||||||
|
matcher = pattern.matcher("\ud800\udc61");
|
||||||
|
matcher.region(0, 1);
|
||||||
|
if (matcher.find()) {
|
||||||
|
failCount++;
|
||||||
|
System.out.println("Matched a surrogate pair" +
|
||||||
|
" that crosses border of region");
|
||||||
|
}
|
||||||
|
if (!matcher.hitEnd()) {
|
||||||
|
failCount++;
|
||||||
|
System.out.println("Expected to hit the end when" +
|
||||||
|
" matching a surrogate pair crossing region");
|
||||||
|
}
|
||||||
|
|
||||||
report("Regions");
|
report("Regions");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user