File tree Expand file tree Collapse file tree
main/java/net/sf/jsqlparser/schema
test/java/net/sf/jsqlparser/schema Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1414public final class Server implements MultiPartName {
1515
1616 public static final Pattern SERVER_PATTERN =
17- Pattern .compile ("\\ [([^\\ ]]+? )(?:\\ \\ ([^\\ ]]+))?\\ ]" );
17+ Pattern .compile ("\\ [([^\\ ]\\ \\ ]+ )(?:\\ \\ ([^\\ ]]+))?\\ ]" );
1818
1919 private String serverName ;
2020
Original file line number Diff line number Diff line change 1010package net .sf .jsqlparser .schema ;
1111
1212import static org .junit .jupiter .api .Assertions .assertEquals ;
13+ import static org .junit .jupiter .api .Assertions .assertTimeoutPreemptively ;
14+
15+ import java .time .Duration ;
1316import org .junit .jupiter .api .Test ;
1417
1518public class ServerTest {
1619
20+ @ Test
21+ public void testCraftedServerNameDoesNotBacktrack () throws Exception {
22+ final StringBuilder sb = new StringBuilder ("[" );
23+ for (int i = 0 ; i < 40000 ; i ++) {
24+ sb .append ("a\\ " );
25+ }
26+ final String crafted = sb .toString ();
27+
28+ // an unterminated bracketed name full of backslashes used to backtrack quadratically
29+ final Server server = assertTimeoutPreemptively (Duration .ofSeconds (2 ),
30+ () -> new Server (crafted ));
31+ assertEquals (crafted , server .getFullyQualifiedName ());
32+ }
33+
1734 @ Test
1835 public void testServerNameParsing () throws Exception {
1936 final String serverName = "LOCALHOST" ;
You can’t perform that action at this time.
0 commit comments