]> source.dussan.org Git - poi.git/commitdiff
Bugzilla 47384 - Fixed ExternalNameRecord to handle unicode names
authorJosh Micich <josh@apache.org>
Thu, 18 Jun 2009 21:01:13 +0000 (21:01 +0000)
committerJosh Micich <josh@apache.org>
Thu, 18 Jun 2009 21:01:13 +0000 (21:01 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@786267 13f79535-47bb-0310-9956-ffa450edef68

src/documentation/content/xdocs/status.xml
src/java/org/apache/poi/hssf/record/ExternalNameRecord.java
src/testcases/org/apache/poi/hssf/record/TestExternalNameRecord.java

index 3157a8418a4f39081a514b945fd499237660976a..fd3c3300460d86a83160f12bba65446320b8f05a 100644 (file)
@@ -33,6 +33,7 @@
 
     <changes>
         <release version="3.5-beta7" date="2009-??-??">
+           <action dev="POI-DEVELOPERS" type="fix">47384 - Fixed ExternalNameRecord to handle unicode names</action>
            <action dev="POI-DEVELOPERS" type="fix">47372 - Fixed locale-sensitive unit tests to pass when running on non-US locale</action>
         </release>
         <release version="3.5-beta6" date="2009-06-22">
index 0ac34880d574e227ef521c0b8f063aa1e1f6481d..3c7d94354c1f1d7bc7b591cb2a2a76d742e227c1 100755 (executable)
@@ -135,8 +135,13 @@ public final class ExternalNameRecord extends StandardRecord {
                field_1_option_flag = in.readShort();
                field_2_index       = in.readShort();
                field_3_not_used    = in.readShort();
-               short nameLength    = in.readShort();
-               field_4_name = in.readCompressedUnicode(nameLength);
+               int nameLength = in.readUByte();
+               int multibyteFlag = in.readUByte();
+               if (multibyteFlag == 0) {
+                       field_4_name = in.readCompressedUnicode(nameLength);
+               } else {
+                       field_4_name = in.readUnicodeLEString(nameLength);
+               }
                if(!hasFormula()) {
                        if (!isStdDocumentNameIdentifier() && !isOLELink() && isAutomaticLink()) {
                                // both need to be incremented
index 5c693d36c2281c36def500163a7d4e917674b3d0..8831f02bedc9c6350f1d1d486591f27901934fdf 100644 (file)
@@ -135,4 +135,28 @@ public final class TestExternalNameRecord extends TestCase {
 
                TestcaseRecordInputStream.confirmRecordEncoding(0x0023, dataDDE, enr.serialize());
        }
+
+       public void testUnicodeName_bug47384() {
+               // 0x13A0
+               byte[] dataUN = HexRead.readFromString(
+                               "23 00 22 00" +
+                               "00 00 00 00 00 00 " +
+                               "0C 01 " +
+                               "59 01 61 00 7A 00 65 00 6E 00 ED 00 5F 00 42 00 69 00 6C 00 6C 00 61 00" +
+                               "00 00");
+
+               RecordInputStream in = TestcaseRecordInputStream.create(dataUN);
+               ExternalNameRecord enr;
+               try {
+                       enr = new ExternalNameRecord(in);
+               } catch (RecordFormatException e) {
+                       // actual msg reported in bugzilla 47229 is different
+                       // because that seems to be using a version from before svn r646666
+                       if (e.getMessage().startsWith("Expected to find a ContinueRecord in order to read remaining 242 of 268 chars")) {
+                               throw new AssertionFailedError("Identified bug 47384 - failed to read ENR with unicode name");
+                       }
+                       throw e;
+               }
+               assertEquals("\u0159azen\u00ED_Billa", enr.getText());
+       }
 }