Skip to content
This repository has been archived by the owner on May 11, 2022. It is now read-only.

Commit

Permalink
Enable validating mode
Browse files Browse the repository at this point in the history
  • Loading branch information
kravietz committed Feb 6, 2019
1 parent ac61a97 commit 38adb4d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/main/java/net/krvtz/resources/XmlResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.xml.XMLConstants;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
Expand Down Expand Up @@ -36,6 +37,8 @@ public Response handle(@QueryParam("input") String input) throws ParserConfigura
// NEVER do this in production code
dbf.setFeature(FEATURE_GENERAL_ENTITIES, true);
dbf.setFeature(FEATURE_PARAMETER_ENTITIES, true);
dbf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, false);
dbf.setValidating(true);
dbf.setXIncludeAware(true);
dbf.setExpandEntityReferences(true);

Expand All @@ -52,7 +55,7 @@ public Response handle(@QueryParam("input") String input) throws ParserConfigura
TransformerFactory transformerFactory = TransformerFactory.newInstance();
Transformer transformer = transformerFactory.newTransformer();
transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no");
transformer.setOutputProperty(OutputKeys.INDENT, "yes");

// Return pretty print xml string
Expand Down

0 comments on commit 38adb4d

Please sign in to comment.