Skip to content

Commit 85014b8

Browse files
committed
Do sanitizing on java level
1 parent cf9b502 commit 85014b8

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/main/java/org/utplsql/api/outputBuffer/OutputBufferProvider.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,18 @@ public static OutputBuffer getCompatibleOutputBuffer(Version databaseVersion, Re
4242

4343
private static boolean hasOutput( Reporter reporter, OracleConnection oraConn ) throws SQLException {
4444

45+
String reporterName = reporter.getTypeName();
46+
if ( !reporterName.matches("^[a-zA-Z0-9_]+$"))
47+
throw new IllegalArgumentException(String.format("Reporter-Name %s is not valid", reporterName));
48+
4549
String sql =
4650
"declare " +
4751
" l_result int;" +
4852
"begin " +
4953
" begin " +
5054
" execute immediate '" +
5155
" begin " +
52-
" :x := case (' || DBMS_ASSERT.SQL_OBJECT_NAME( ? ) || '() is of (ut_output_reporter_base)) when true then 1 else 0 end;" +
56+
" :x := case ' || ? || '() is of (ut_output_reporter_base) when true then 1 else 0 end;" +
5357
" end;'" +
5458
" using out l_result;" +
5559
" end;" +
@@ -58,13 +62,13 @@ private static boolean hasOutput( Reporter reporter, OracleConnection oraConn )
5862

5963
try ( CallableStatement stmt = oraConn.prepareCall(sql)) {
6064
stmt.setQueryTimeout(3);
61-
stmt.setString(1, reporter.getTypeName());
65+
stmt.setString(1, reporterName);
6266
stmt.registerOutParameter(2, OracleTypes.INTEGER);
6367

6468
stmt.execute();
6569
int result = stmt.getInt(2);
6670

67-
System.out.println("Output-check for " + reporter.getTypeName() + ": " + result);
71+
System.out.println("Output-check for " + reporterName + ": " + result);
6872
return result == 1;
6973
}
7074
}

0 commit comments

Comments
 (0)