Skip to content

Commit f14cff5

Browse files
author
GWA
committed
Bug fix: Fixed StringIndexOutOfBoundsException when executed SQL contains the German Umlaut sz
1 parent 7792a60 commit f14cff5

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

sql12/core/doc/changes.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ Table cell data popup now offers find, Xml/Json-reformatting and export function
5757

5858
Bug fixes:
5959

60+
Fixed StringIndexOutOfBoundsException when executed SQL contains the German Umlaut sz.
61+
6062
Change tracking, left gutter popup to show deleted changes:
6163
Fixed Nullpointer when popup was too long.
6264

sql12/core/src/net/sourceforge/squirrel_sql/fw/sql/tablenamefind/TableNameFindService.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
package net.sourceforge.squirrel_sql.fw.sql.tablenamefind;
22

3+
import java.sql.ResultSet;
4+
import java.sql.ResultSetMetaData;
5+
import java.sql.SQLException;
6+
import java.util.regex.Matcher;
7+
import java.util.regex.Pattern;
8+
39
import net.sourceforge.squirrel_sql.client.session.ISession;
410
import net.sourceforge.squirrel_sql.client.session.action.sqlscript.SQLScriptServices;
511
import net.sourceforge.squirrel_sql.fw.datasetviewer.ColumnDisplayDefinition;
612
import net.sourceforge.squirrel_sql.fw.sql.ITableInfo;
713
import net.sourceforge.squirrel_sql.fw.sql.TableInfo;
814
import net.sourceforge.squirrel_sql.fw.util.StringUtilities;
915

10-
import java.sql.ResultSet;
11-
import java.sql.ResultSetMetaData;
12-
import java.sql.SQLException;
13-
import java.util.regex.Matcher;
14-
import java.util.regex.Pattern;
15-
1616
public class TableNameFindService
1717
{
1818
private static final Pattern FILL_COLUMN_NAME_PATTERN = Pattern.compile(".+:([^:]+):[^:]+$");
@@ -56,9 +56,10 @@ private static String _findTableNameInSQL(String sql)
5656
}
5757

5858
// Get the table name in its original upper-lower case.
59-
String table = sql.trim().substring(matcher.start(1), matcher.end(1));
59+
int matchEnd = Math.min(sql.trim().length(), matcher.end(1)); // Prevents StringIndexOutOfBoundsException when sql contains German sz-Umlaut.
60+
String table = sql.trim().substring(matcher.start(1), matchEnd);
6061

61-
String behindTable = ucSql.substring(matcher.end(1)).trim();
62+
String behindTable = ucSql.substring(matchEnd).trim();
6263

6364
SingleTableSqlEnum ret = behindTableAllowsEditing(behindTable);
6465

0 commit comments

Comments
 (0)