ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 34425] New: - Manifest cause StringIndexOutOfBound error while processing multibyte characters
Date Wed, 13 Apr 2005 02:54:37 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=34425>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=34425

           Summary: Manifest cause StringIndexOutOfBound error while
                    processing multibyte characters
           Product: Ant
           Version: 1.6.2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Core tasks
        AssignedTo: dev@ant.apache.org
        ReportedBy: lt@basecity.com


Manifest task try to trancate multi-byte attributes by substring it to find out
which position of the 72nd byte is, but when a line has more than 72 bytes, but
has less than 72 characters, a runtime exception will be raised. Besides, the
source code just call String.getBytes() method, that method depends on the
default charset of the platform, it should be change to getBytes("UTF-8"),
because a menifest is supposed to be written in UTF-8.

and below is my patch:
Index: src/main/org/apache/tools/ant/taskdefs/Manifest.java
===================================================================
RCS file: /home/cvspublic/ant/src/main/org/apache/tools/ant/taskdefs/Manifest.java,v
retrieving revision 1.48.2.5
diff -u -r1.48.2.5 Manifest.java
--- src/main/org/apache/tools/ant/taskdefs/Manifest.java	9 Mar 2004 17:01:33
-0000	1.48.2.5
+++ src/main/org/apache/tools/ant/taskdefs/Manifest.java	11 Apr 2005 03:56:32 -0000
@@ -300,11 +300,11 @@
         private void writeValue(PrintWriter writer, String value)
              throws IOException {
             String line = name + ": " + value;
-            while (line.getBytes().length > MAX_LINE_LENGTH) {
+            while (line.getBytes("UTF-8").length > MAX_LINE_LENGTH) {
                 // try to find a MAX_LINE_LENGTH byte section
-                int breakIndex = MAX_SECTION_LENGTH;
+                int breakIndex = line.length() > MAX_SECTION_LENGTH ?
MAX_SECTION_LENGTH : line.length();
                 String section = line.substring(0, breakIndex);
-                while (section.getBytes().length > MAX_SECTION_LENGTH
+                while (section.getBytes("UTF-8").length > MAX_SECTION_LENGTH
                      && breakIndex > 0) {
                     breakIndex--;
                     section = line.substring(0, breakIndex);

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message