File tree Expand file tree Collapse file tree 2 files changed +10
-3
lines changed
src/main/java/uk/gov/hmcts/cp/controllers Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -226,7 +226,7 @@ dependencies {
226226
227227 implementation group : ' io.rest-assured' , name : ' rest-assured' , version : ' 5.5.5'
228228 implementation ' org.hibernate.validator:hibernate-validator:9.0.0.Final'
229- implementation ' org.apache.commons:commons-lang3:3.17.0 '
229+ implementation ' org.apache.commons:commons-text:1.13.1 '
230230
231231 compileOnly group : ' org.projectlombok' , name : ' lombok' , version : lombokVersion
232232 annotationProcessor group : ' org.projectlombok' , name : ' lombok' , version : lombokVersion
Original file line number Diff line number Diff line change 11package uk .gov .hmcts .cp .controllers ;
22
3+ import org .apache .commons .text .StringEscapeUtils ;
34import org .slf4j .Logger ;
45import org .slf4j .LoggerFactory ;
56import org .springframework .http .HttpStatus ;
@@ -21,15 +22,21 @@ public CourtScheduleController(CourtScheduleService courtScheduleService) {
2122
2223 @ Override
2324 public ResponseEntity <CourtScheduleResponse > getCourtScheduleByCaseUrn (String caseUrn ) {
25+ String sanitizedCaseUrn ;
2426 CourtScheduleResponse courtScheduleResponse ;
2527 try {
26- courtScheduleResponse = courtScheduleService .getCourtScheduleResponse (caseUrn );
28+ sanitizedCaseUrn = sanitizeCaseUrn (caseUrn );
29+ courtScheduleResponse = courtScheduleService .getCourtScheduleResponse (sanitizedCaseUrn );
2730 } catch (ResponseStatusException e ) {
2831 log .error (e .getMessage ());
2932 return ResponseEntity .status (e .getStatusCode ()).build ();
3033 }
31- log .debug ("getCourtScheduleByCaseUrn : {}" , caseUrn );
34+ log .debug ("Found court schedule for caseUrn : {}" , sanitizedCaseUrn );
3235 return new ResponseEntity <>(courtScheduleResponse , HttpStatus .OK );
3336 }
3437
38+ private String sanitizeCaseUrn (String urn ) {
39+ if (urn == null ) throw new ResponseStatusException (HttpStatus .BAD_REQUEST , "caseUrn is required" );;
40+ return StringEscapeUtils .escapeHtml4 (urn );
41+ }
3542}
You can’t perform that action at this time.
0 commit comments