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 2A38F7314 for ; Thu, 14 Jul 2011 13:29:23 +0000 (UTC) Received: (qmail 73715 invoked by uid 500); 14 Jul 2011 13:29:22 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 73651 invoked by uid 500); 14 Jul 2011 13:29:21 -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 73642 invoked by uid 99); 14 Jul 2011 13:29:21 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 14 Jul 2011 13:29:21 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,T_RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.116] (HELO hel.zones.apache.org) (140.211.11.116) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 14 Jul 2011 13:29:20 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id E4BA5578AF for ; Thu, 14 Jul 2011 13:28:59 +0000 (UTC) Date: Thu, 14 Jul 2011 13:28:59 +0000 (UTC) From: "Taro Yabuki (JIRA)" To: issues@commons.apache.org Message-ID: <513282225.13339.1310650139933.JavaMail.tomcat@hel.zones.apache.org> In-Reply-To: <589345962.13324.1310649900804.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] [Updated] (LANG-720) StringEscapeUtils.escapeXml(input) outputs wrong results when an input contains characters in Supplementary Planes. 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-720?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Taro Yabuki updated LANG-720: ----------------------------- Attachment: CharSequenceTranslator.java.20110714.diff Patch for org/apache/commons/lang3/text/translate/CharSequenceTranslator.java. > StringEscapeUtils.escapeXml(input) outputs wrong results when an input contains characters in Supplementary Planes. > ------------------------------------------------------------------------------------------------------------------- > > Key: LANG-720 > URL: https://issues.apache.org/jira/browse/LANG-720 > Project: Commons Lang > Issue Type: Bug > Components: lang.*, lang.text.translate.* > Affects Versions: 3.0 > Reporter: Taro Yabuki > Labels: patch > Attachments: CharSequenceTranslator.java.20110714.diff > > > Hello. > I use StringEscapeUtils.escapeXml(input) to escape special characters for XML. > This method outputs wrong results when input contains characters in Supplementary Planes. > String str1 = "\uD842\uDFB7" + "A"; > String str2 = StringEscapeUtils.escapeXml(str1); > // The value of str2 must be equal to the one of str1, > // because str1 does not contain characters to be escaped. > // However, str2 is diffrent from str1. > System.out.println(URLEncoder.encode(str1, "UTF-16BE")); //%D8%42%DF%B7A > System.out.println(URLEncoder.encode(str2, "UTF-16BE")); //%D8%42%DF%B7%FF%FD > The cause of this problem is that the loop to translate input character by character is wrong. > In CharSequenceTranslator.translate(CharSequence input, Writer out), > loop counter "i" moves from 0 to Character.codePointCount(input, 0, input.length()), > but it should move from 0 to input.length(). -- This message is automatically generated by JIRA. For more information on JIRA, see: http://www.atlassian.com/software/jira