diff --git a/src/main/java/it/gov/pagopa/wispconverter/controller/ReceiptController.java b/src/main/java/it/gov/pagopa/wispconverter/controller/ReceiptController.java index ce103c30..f4d79e7b 100644 --- a/src/main/java/it/gov/pagopa/wispconverter/controller/ReceiptController.java +++ b/src/main/java/it/gov/pagopa/wispconverter/controller/ReceiptController.java @@ -30,9 +30,7 @@ import org.springframework.web.ErrorResponse; import org.springframework.web.bind.annotation.*; import org.xml.sax.InputSource; -import org.xml.sax.SAXException; -import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.SAXParserFactory; import java.io.IOException; import java.io.StringReader; @@ -144,21 +142,19 @@ public void receiptOk(@RequestBody ReceiptRequest request) throws IOException { } private String getReceiptRequestInfoToLog(String xml) { - String args = "n/a"; + String args = ""; try { if (StringUtils.isNotEmpty(xml)) { // fix for sonar issue XML external entity in user-controlled data saxParserFactory.setFeature("http://xml.org/sax/features/external-general-entities", false); saxParserFactory.setFeature("http://xml.org/sax/features/external-parameter-entities", false); saxParserFactory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); - saxParserFactory.newSAXParser().parse(new InputSource(new StringReader(xml)), receiptRequestHandler); - PaSendRTV2Request result = receiptRequestHandler.getPaSendRTV2Request(); args = "noticeNumber=" + result.getNoticeNumber() + ", fiscalCode=" + result.getFiscalCode() + ", creditorReferenceId=" + result.getCreditorReferenceId(); } - } catch (SAXException | IOException | ParserConfigurationException e) { - return args; + } catch (Exception e) { + args = "n/a"; } return args; }