Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@
return name;
}

public static String escape(final String val) {

Check warning on line 52 in com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/LibSqlUtils.java

View workflow job for this annotation

GitHub Actions / Check / Lint

[checkstyle] reported by reviewdog 🐶 Reference type 'String' is missing a nullability annotation. Raw Output: /github/workspace/com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/LibSqlUtils.java:52:39: warning: Reference type 'String' is missing a nullability annotation. (sh.adelessfox.checkstyle.checks.NullabilityAnnotationsCheck)

Check warning on line 52 in com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/LibSqlUtils.java

View workflow job for this annotation

GitHub Actions / Check / Lint

[checkstyle] reported by reviewdog 🐶 Reference type 'String' is missing a nullability annotation. Raw Output: /github/workspace/com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/LibSqlUtils.java:52:19: warning: Reference type 'String' is missing a nullability annotation. (sh.adelessfox.checkstyle.checks.NullabilityAnnotationsCheck)
if (val.indexOf('\'') == 1) {
if (val.indexOf('\'') == -1) {
return val;
}
int len = val.length();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,26 @@
assertUrlFormat("libsql://turso.url.my-hostname-1:8080", "https://turso.url.my-hostname-1:8080");
}

private void assertUrlFormat(String input, String expected) throws LibSqlException {

Check warning on line 45 in com.dbeaver.jdbc.driver.libsql/src/test/java/com/dbeaver/jdbc/upd/driver/test/LibSqlUtilsTest.java

View workflow job for this annotation

GitHub Actions / Check / Lint

[checkstyle] reported by reviewdog 🐶 Reference type 'String' is missing a nullability annotation. Raw Output: /github/workspace/com.dbeaver.jdbc.driver.libsql/src/test/java/com/dbeaver/jdbc/upd/driver/test/LibSqlUtilsTest.java:45:48: warning: Reference type 'String' is missing a nullability annotation. (sh.adelessfox.checkstyle.checks.NullabilityAnnotationsCheck)

Check warning on line 45 in com.dbeaver.jdbc.driver.libsql/src/test/java/com/dbeaver/jdbc/upd/driver/test/LibSqlUtilsTest.java

View workflow job for this annotation

GitHub Actions / Check / Lint

[checkstyle] reported by reviewdog 🐶 Reference type 'String' is missing a nullability annotation. Raw Output: /github/workspace/com.dbeaver.jdbc.driver.libsql/src/test/java/com/dbeaver/jdbc/upd/driver/test/LibSqlUtilsTest.java:45:34: warning: Reference type 'String' is missing a nullability annotation. (sh.adelessfox.checkstyle.checks.NullabilityAnnotationsCheck)
Assertions.assertEquals(expected, LibSqlUtils.validateAndFormatUrl(input));
}

@Test
public void testEscape() {
// No quote: returned unchanged.
Assertions.assertEquals("table", LibSqlUtils.escape("table"));
Assertions.assertEquals("", LibSqlUtils.escape(""));

// Every single quote must be doubled, wherever it sits.
Assertions.assertEquals("''", LibSqlUtils.escape("'"));
Assertions.assertEquals("a''b", LibSqlUtils.escape("a'b"));
Assertions.assertEquals("''ab", LibSqlUtils.escape("'ab"));
Assertions.assertEquals("ab''", LibSqlUtils.escape("ab'"));

// Regression: a quote at index 1 used to be returned un-escaped
// (guard was `== 1` instead of `== -1`), letting the quote close the
// surrounding SQL string literal in concatenated metadata queries.
Assertions.assertEquals("x''", LibSqlUtils.escape("x'"));
Assertions.assertEquals("x'' OR ''1''=''1", LibSqlUtils.escape("x' OR '1'='1"));
}
}
Loading