aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJenkins CI <ci@sonarsource.com>2014-10-22 08:01:25 +0200
committerJenkins CI <ci@sonarsource.com>2014-10-22 08:01:25 +0200
commit9c03512e5342c127ce904ffa2a8a0e42d1819826 (patch)
treedf73730eb665806807a68a02cb1236d1594242b9
parent25debfae898192808b76e1617e0b7d27e029deb2 (diff)
parent67e2a0659d60ff3825b6119539c0344f5ac80be7 (diff)
downloadsonarqube-9c03512e5342c127ce904ffa2a8a0e42d1819826.tar.gz
sonarqube-9c03512e5342c127ce904ffa2a8a0e42d1819826.zip
Automatic merge from branch-4.5
* origin/branch-4.5: SONAR-5758 fix quality flaws
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/db/migrations/v451/DeleteUnescapedActivities.java14
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/db/migrations/v451/DeleteUnescapedActivitiesTest.java4
2 files changed, 13 insertions, 5 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v451/DeleteUnescapedActivities.java b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v451/DeleteUnescapedActivities.java
index 5f9866de881..c0bbe4fa71a 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v451/DeleteUnescapedActivities.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v451/DeleteUnescapedActivities.java
@@ -26,6 +26,8 @@ import org.sonar.server.db.migrations.MassUpdate;
import org.sonar.server.db.migrations.Select;
import org.sonar.server.db.migrations.SqlStatement;
+import javax.annotation.Nullable;
+
import java.sql.SQLException;
/**
@@ -57,11 +59,13 @@ public class DeleteUnescapedActivities extends BaseDataChange {
});
}
- static boolean isUnescaped(String csv) {
- String[] splits = csv.split(";");
- for (String split : splits) {
- if (StringUtils.countMatches(split, "=") != 1) {
- return true;
+ static boolean isUnescaped(@Nullable String csv) {
+ if (csv != null) {
+ String[] splits = StringUtils.split(csv, ';');
+ for (String split : splits) {
+ if (StringUtils.countMatches(split, "=") != 1) {
+ return true;
+ }
}
}
return false;
diff --git a/server/sonar-server/src/test/java/org/sonar/server/db/migrations/v451/DeleteUnescapedActivitiesTest.java b/server/sonar-server/src/test/java/org/sonar/server/db/migrations/v451/DeleteUnescapedActivitiesTest.java
index 4f342cfe5a8..cb13eb73884 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/db/migrations/v451/DeleteUnescapedActivitiesTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/db/migrations/v451/DeleteUnescapedActivitiesTest.java
@@ -47,7 +47,11 @@ public class DeleteUnescapedActivitiesTest {
"ruleKey=findbugs:PT_RELATIVE_PATH_TRAVERSAL;profileKey=java-findbugs-74105;severity=MAJOR;" +
"key=java-findbugs-74105:findbugs:PT_RELATIVE_PATH_TRAVERSAL"))
.isFalse();
+ assertThat(DeleteUnescapedActivities.isUnescaped(null)).isFalse();
+ assertThat(DeleteUnescapedActivities.isUnescaped("")).isFalse();
+ assertThat(DeleteUnescapedActivities.isUnescaped("foo=bar")).isFalse();
assertThat(DeleteUnescapedActivities.isUnescaped("param_xpath=/foo/bar")).isFalse();
+
assertThat(DeleteUnescapedActivities.isUnescaped("param_xpath=/foo/bar;foo;ruleKey=S001")).isTrue();
assertThat(DeleteUnescapedActivities.isUnescaped("param_xpath=/foo=foo;ruleKey=S001")).isTrue();