mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 07:14:30 +02:00
8281560: Matcher.hitEnd returns unexpected results in presence of CANON_EQ flag.
Reviewed-by: rriggs, lancea
This commit is contained in:
parent
2549e55038
commit
3fc009be8a
2 changed files with 27 additions and 2 deletions
|
@ -4005,8 +4005,9 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) {
|
|||
}
|
||||
if (j < matcher.to)
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
matcher.hitEnd = true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -4557,12 +4557,36 @@ public class RegExTest {
|
|||
assertTrue(e.getMessage().contains("Bad intersection syntax"));
|
||||
}
|
||||
|
||||
//This test is for 8281560
|
||||
@Test
|
||||
public static void prematureHitEndInNFCCharProperty() {
|
||||
var testInput = "a1a1";
|
||||
var pat1 = "(a+|1+)";
|
||||
var pat2 = "([a]+|[1]+)";
|
||||
|
||||
var matcher1 = Pattern.compile(pat1, Pattern.CANON_EQ).matcher(testInput);
|
||||
var matcher2 = Pattern.compile(pat2, Pattern.CANON_EQ).matcher(testInput);
|
||||
|
||||
ArrayList<Boolean> results1 = new ArrayList<>();
|
||||
ArrayList<Boolean> results2 = new ArrayList<>();
|
||||
|
||||
while (matcher1.find()) {
|
||||
results1.add(matcher1.hitEnd());
|
||||
}
|
||||
|
||||
while (matcher2.find()) {
|
||||
results2.add(matcher2.hitEnd());
|
||||
}
|
||||
|
||||
assertEquals(results1, results2);
|
||||
}
|
||||
|
||||
//This test is for 8281315
|
||||
@Test
|
||||
public static void iOOBForCIBackrefs(){
|
||||
String line = "\ud83d\udc95\ud83d\udc95\ud83d\udc95";
|
||||
var pattern2 = Pattern.compile("(?i)(.)\\1{2,}");
|
||||
assertTrue(pattern2.matcher(line).find());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue