Browse Source

NamedParameterUtils.isParameterSeparator checks for non-ASCII characters

Issue: SPR-16472
pull/1666/head
Juergen Hoeller 7 years ago
parent
commit
ac7a699356
  1. 2
      spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/NamedParameterUtils.java
  2. 10
      spring-jdbc/src/test/java/org/springframework/jdbc/core/namedparam/NamedParameterUtilsTests.java

2
spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/NamedParameterUtils.java

@ -391,7 +391,7 @@ public abstract class NamedParameterUtils { @@ -391,7 +391,7 @@ public abstract class NamedParameterUtils {
* that is, whether the given character qualifies as a separator.
*/
private static boolean isParameterSeparator(char c) {
return (separatorIndex[c] || Character.isWhitespace(c));
return (c < 128 && separatorIndex[c]) || Character.isWhitespace(c);
}
/**

10
spring-jdbc/src/test/java/org/springframework/jdbc/core/namedparam/NamedParameterUtilsTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -52,11 +52,11 @@ public class NamedParameterUtilsTests { @@ -52,11 +52,11 @@ public class NamedParameterUtilsTests {
assertEquals(2, psql2.getTotalParameterCount());
assertEquals(1, psql2.getNamedParameterCount());
String sql3 = "xxx &a+:b" + '\t' + ":c%10 yyyy ? zzzzz";
String sql3 = "xxx &ä+:ö" + '\t' + ":ü%10 yyyy ? zzzzz";
ParsedSql psql3 = NamedParameterUtils.parseSqlStatement(sql3);
assertEquals("a", psql3.getParameterNames().get(0));
assertEquals("b", psql3.getParameterNames().get(1));
assertEquals("c", psql3.getParameterNames().get(2));
assertEquals("ä", psql3.getParameterNames().get(0));
assertEquals("ö", psql3.getParameterNames().get(1));
assertEquals("ü", psql3.getParameterNames().get(2));
}
@Test

Loading…
Cancel
Save