File tree Expand file tree Collapse file tree
main/java/net/sf/jsqlparser/expression
test/java/net/sf/jsqlparser/expression Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ public class OracleHint extends ASTNodeAccessImpl implements Expression {
2424
2525 private static final Pattern SINGLE_LINE = Pattern .compile ("--\\ + *([^ ].*[^ ])" );
2626 private static final Pattern MULTI_LINE =
27- Pattern .compile ("/\\ *\\ + *([^ ].*[^ ]) *\\ *+/" , Pattern .MULTILINE | Pattern .DOTALL );
27+ Pattern .compile ("\\ A /\\ *\\ + *([^ ].*[^ ]) *\\ *+/" , Pattern .MULTILINE | Pattern .DOTALL );
2828
2929 private String value ;
3030 private boolean singleLine = false ;
Original file line number Diff line number Diff line change 99 */
1010package net .sf .jsqlparser .expression ;
1111
12+ import static org .junit .jupiter .api .Assertions .assertFalse ;
13+ import static org .junit .jupiter .api .Assertions .assertTimeoutPreemptively ;
14+
15+ import java .time .Duration ;
1216import net .sf .jsqlparser .JSQLParserException ;
1317import net .sf .jsqlparser .test .TestUtils ;
1418import org .junit .jupiter .api .Test ;
@@ -46,4 +50,18 @@ void testMerge() throws JSQLParserException {
4650 TestUtils .assertSqlCanBeParsedAndDeparsed (sqlString , true );
4751 }
4852
53+ @ Test
54+ void testCraftedHintCommentDoesNotBacktrack () {
55+ final StringBuilder sb = new StringBuilder ("-- /*+ " );
56+ for (int i = 0 ; i < 100000 ; i ++) {
57+ sb .append ('*' );
58+ }
59+ final String crafted = sb .toString ();
60+
61+ // a line comment carrying an unterminated /*+ marker (no closing */) used to make the
62+ // block hint pattern backtrack quadratically, and it is not an oracle hint anyway
63+ assertTimeoutPreemptively (Duration .ofSeconds (2 ),
64+ () -> assertFalse (OracleHint .isHintMatch (crafted )));
65+ }
66+
4967}
You can’t perform that action at this time.
0 commit comments