Return-Path: X-Original-To: apmail-commons-issues-archive@minotaur.apache.org Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 1DD7610914 for ; Sat, 15 Feb 2014 16:15:25 +0000 (UTC) Received: (qmail 75826 invoked by uid 500); 15 Feb 2014 16:15:23 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 75468 invoked by uid 500); 15 Feb 2014 16:15:22 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 75457 invoked by uid 99); 15 Feb 2014 16:15:20 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 15 Feb 2014 16:15:20 +0000 Date: Sat, 15 Feb 2014 16:15:20 +0000 (UTC) From: "Benedikt Ritter (JIRA)" To: issues@commons.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Resolved] (LANG-955) Add methods for removing all invalid characters according to XML 1.0 and XML 1.1 in an input string to StringEscapeUtils MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/LANG-955?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Benedikt Ritter resolved LANG-955. ---------------------------------- Resolution: Fixed Fix Version/s: (was: Review Patch) {code} Sending src/changes/changes.xml Sending src/main/java/org/apache/commons/lang3/StringEscapeUtils.java Adding src/main/java/org/apache/commons/lang3/text/translate/UnicodeUnpairedSurrogateRemover.java Sending src/test/java/org/apache/commons/lang3/StringEscapeUtilsTest.java Adding src/test/java/org/apache/commons/lang3/text/translate/UnicodeUnpairedSurrogateRemoverTest.java Transmitting file data ..... Committed revision 1568639. {code} Thanks for contributing! > Add methods for removing all invalid characters according to XML 1.0 and XML 1.1 in an input string to StringEscapeUtils > ------------------------------------------------------------------------------------------------------------------------ > > Key: LANG-955 > URL: https://issues.apache.org/jira/browse/LANG-955 > Project: Commons Lang > Issue Type: Improvement > Components: lang.* > Affects Versions: 3.1 > Environment: Ubuntu 13.10 > Reporter: Adam Hooper > Assignee: Benedikt Ritter > Labels: xml > Fix For: 3.3 > > > escapeXml lets non-text characters pass through into XML files: > {code} > scala> org.apache.commons.lang3.StringEscapeUtils.escapeXml("\u0004").codePointAt(0) > res4: Int = 4 > {code} > I would expect the result to be an exception -- either from StringEscapeUtils (refusing to encode it) or, preferably, from String.codePointAt, complaining that the string is empty. \u0004 is not a valid character in XML 1.0, and there is no way to represent it in an XML document -- not even by escaping it. > Wikipedia summarizes the characters that are not allowed in XML -- even after escaping: http://en.wikipedia.org/wiki/Valid_characters_in_XML. The reason for disallowing them: XML is a text interchange format, and control characters are not text. > If StringEscapeUtils.escapeXml allows invalid XML characters through -- whether escaped or not -- it generates invalid XML. Valid XML parsers will refuse to read such files. -- This message was sent by Atlassian JIRA (v6.1.5#6160)