Skip to content
This repository was archived by the owner on Mar 27, 2025. It is now read-only.

Commit a03b5a9

Browse files
author
Nikhil Bhoski
committed
Updated the escape logic for single quotes
1 parent 5b284ba commit a03b5a9

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

src/main/java/com/mathworks/ci/RunMatlabTestsStep.java

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ private String getInputArgs() {
145145

146146
args.forEach((key, val) -> {
147147
if (val != null) {
148-
inputArgs.add("'" + key + "'" + "," + "'" + val + "'");
148+
inputArgs.add("'" + key + "'" + "," + "'" + val.replaceAll("'", "''") + "'");
149149
}
150150
});
151151

@@ -158,18 +158,12 @@ private String getInputArgs() {
158158

159159
private Map<String, String> getMatlabArgs() {
160160
final Map<String, String> args = new HashMap<String, String>();
161-
args.put(PDF_REPORT_PATH,
162-
getTestResultsPDF() == null ? null : getTestResultsPDF().replaceAll("'", "''"));
163-
args.put(TAP_RESULTS_PATH,
164-
getTestResultsTAP() == null ? null : getTestResultsTAP().replaceAll("'", "''"));
165-
args.put(JUNIT_RESULTS_PATH,
166-
getTestResultsJUnit() == null ? null : getTestResultsJUnit().replaceAll("'", "''"));
167-
args.put(STM_RESULTS_PATH, getTestResultsSimulinkTest() == null ? null
168-
: getTestResultsSimulinkTest().replaceAll("'", "''"));
169-
args.put(COBERTURA_CODE_COVERAGE_PATH, getCodeCoverageCobertura() == null ? null
170-
: getCodeCoverageCobertura().replaceAll("'", "''"));
171-
args.put(COBERTURA_MODEL_COVERAGE_PATH, getModelCoverageCobertura() == null ? null
172-
: getModelCoverageCobertura().replaceAll("'", "''"));
161+
args.put(PDF_REPORT_PATH,getTestResultsPDF());
162+
args.put(TAP_RESULTS_PATH,getTestResultsTAP());
163+
args.put(JUNIT_RESULTS_PATH,getTestResultsJUnit());
164+
args.put(STM_RESULTS_PATH, getTestResultsSimulinkTest());
165+
args.put(COBERTURA_CODE_COVERAGE_PATH, getCodeCoverageCobertura());
166+
args.put(COBERTURA_MODEL_COVERAGE_PATH, getModelCoverageCobertura());
173167
return args;
174168
}
175169

0 commit comments

Comments
 (0)