Skip to content

Commit

Permalink
purify characters from environment variables which contain characters…
Browse files Browse the repository at this point in the history
… invalid in XML
  • Loading branch information
Conal-Tuohy committed May 13, 2015
1 parent 0db348f commit f1f9d0d
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/com/conaltuohy/xprocz/XProcZServlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,18 @@ public void run() {
};

private void addParameter(String prefix, String xmlns, String localName, String value) {
QName name = new QName(prefix, xmlns, localName);
QName name = new QName(prefix, xmlns, purifyForXML(localName));
getServletContext().log("XProc-Z parameter <c:param name='" + name + "' value='" + value + "'/>");
parameters.put(name, value);
parameters.put(name, purifyForXML(value));
};

/**
* Remove characters which are invalid or discouraged in XML
*/
private String purifyForXML(String text) {
return text.replaceAll("[^\\u0009\\u000a\\u000d\\u0020-\\ud7ff\\ue000-\\ufffd]", "");
}

public void init() throws ServletException {
getServletContext().log("XProc-Z initializing ...");
try {
Expand Down

0 comments on commit f1f9d0d

Please sign in to comment.