You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Muhammed Syyid <ms...@gmail.com> on 2005/04/27 19:18:38 UTC

FontRecord problem

Hi
An excel workbook of mine is causing an exception (mentioned below). I've 
tried tracing the code and it seems that a FontRecord is created with byte 
14 > 0 which in turn causes 
field_10_font_name_len > 0 causing unicode decoding code to be invoked which 
produces the exception itself. I've followed the codepath and the data array 
is filled directly from the inputstream, retrieving a +ve 124 for data[14]. 

Caused by: java.lang.IllegalArgumentException: Illegal length
at org.apache.poi.util.StringUtil.getFromUnicodeLE(StringUtil.java:78)
at org.apache.poi.hssf.record.FontRecord.fillFields(FontRecord.java:146)
at org.apache.poi.hssf.record.Record.fillFields(Record.java:91)
at org.apache.poi.hssf.record.Record.<init>(Record.java:55)
at org.apache.poi.hssf.record.FontRecord.<init>(FontRecord.java:88)
... 25 more

The exception is thrown in getFromUnicodeLE but i havent encountered that 
method usually being called to begin with. Any ideas on what to do? I found 
a bunch of similar bugs but nothing specifically referring to 
getFromUnicodeLE or FontRecord. 

Thanks a bunch

Muhammed
PS I went through the openoffice documentation but didnt find anything 
specifically referencing a font record or what valid values its data record 
should contain @ the mentioned offset.

Re: FontRecord problem

Posted by an...@superlinksoftware.com.
What version of POI/HSSF?

I bet this is a recent bug.

-andy

Muhammed Syyid wrote:
> Hi
> An excel workbook of mine is causing an exception (mentioned below). I've 
> tried tracing the code and it seems that a FontRecord is created with byte 
> 14 > 0 which in turn causes 
> field_10_font_name_len > 0 causing unicode decoding code to be invoked which 
> produces the exception itself. I've followed the codepath and the data array 
> is filled directly from the inputstream, retrieving a +ve 124 for data[14]. 
> 
> Caused by: java.lang.IllegalArgumentException: Illegal length
> at org.apache.poi.util.StringUtil.getFromUnicodeLE(StringUtil.java:78)
> at org.apache.poi.hssf.record.FontRecord.fillFields(FontRecord.java:146)
> at org.apache.poi.hssf.record.Record.fillFields(Record.java:91)
> at org.apache.poi.hssf.record.Record.<init>(Record.java:55)
> at org.apache.poi.hssf.record.FontRecord.<init>(FontRecord.java:88)
> .. 25 more
> 
> The exception is thrown in getFromUnicodeLE but i havent encountered that 
> method usually being called to begin with. Any ideas on what to do? I found 
> a bunch of similar bugs but nothing specifically referring to 
> getFromUnicodeLE or FontRecord. 
> 
> Thanks a bunch
> 
> Muhammed
> PS I went through the openoffice documentation but didnt find anything 
> specifically referencing a font record or what valid values its data record 
> should contain @ the mentioned offset.
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/


Re: FontRecord problem

Posted by Muhammed Syyid <ms...@gmail.com>.
Hi
Sorry for the delayed email. I've posted the issue as bug 34727 on bugzilla. 
Also the spreadsheet was created using excel and the data[14] value was 124 
and data[15] as 109, the byte array passed in is 26 characters and 
field_10_font_name_len is 124. Thanks again and sorry for the delay.

Muhammed

On 4/28/05, avik.sengupta@itellix.com <av...@itellix.com> wrote:
> 
> Would you mind sending the file to me directly?
> 
> As for the version, file it under HEAD, doesnt matter all that much :)
> 
> Quoting Muhammed Syyid <ms...@gmail.com>:
> 
> > I found the bugzilla page but i'm not sure about which version to post 
> it=
> > =20
> > under. I just got HEAD from cvs. Looking at the build file, its got a=20
> > property tag set @ "version.id" value=3D"2.1", should I file it under
> > 2.0final? Also about the bug itself, i've reproduced it in the current
> > stable
> > build as well the HEAD version i got. Sorry for being a pain but I 
> can't=20
> > submit the xls file, i've stripped all the data and can still recreate 
> the=
> > =20
> > problem but didn't get authorization to post it on the web. If one of 
> you=
> > =20
> > guys want to take a look i'll be more then happy to send it directly? 
> Thanks
> >
> > Muhammed
> >
> > On 4/27/05, avik.sengupta@itellix.com <av...@itellix.com> wrote:
> >> =20
> >> Sounds like a bug, thanks for the detailed investigation, could you 
> please
> >> submit this to bugzilla, and and attach the offending sheet as well? 
> this=
> > =20
> 
> 
> >> will
> >> ensure that this issue does not drop thru the cracks.
> >> =20
> >> I was wondering, however, why all sheets dont show this 
> problem....ie,=20
> >> what
> >> triggers the issue, is it non-ascii font name itself? I presume your 
> shee=
> > t=20
> >> is
> >> created by excel, rather than poi?
> >> =20
> >> Regards
> >> -
> >> Avik
> >> =20
> >> Quoting Muhammed Syyid <ms...@gmail.com>:
> >> =20
> >> > Hi
> >> > An excel workbook of mine is causing an exception (mentioned 
> below).=20
> >> I've=3D
> >> > =3D20
> >> > tried tracing the code and it seems that a FontRecord is created 
> with=
> > =20
> >> byte=3D
> >> > =3D20
> >> > 14 > 0 which in turn causes=3D20
> >> > field_10_font_name_len > 0 causing unicode decoding code to be 
> invoked=
> > =20
> >> whic=3D
> >> > h=3D20
> >> > produces the exception itself. I've followed the codepath and the 
> data=
> > =20
> >> arra=3D
> >> > y=3D20
> >> > is filled directly from the inputstream, retrieving a +ve 124 for=20
> >> data[14].=3D
> >> > =3D20
> >> >
> >> > Caused by: java.lang.IllegalArgumentException: Illegal length
> >> > at org.apache.poi.util.StringUtil.getFromUnicodeLE(StringUtil.java
> :78)
> >> > at org.apache.poi.hssf.record.FontRecord.fillFields(FontRecord.java
> :146)
> >> > at org.apache.poi.hssf.record.Record.fillFields(Record.java:91)
> >> > at org.apache.poi.hssf.record.Record.<init>(Record.java:55)
> >> > at org.apache.poi.hssf.record.FontRecord.<init>(FontRecord.java:88)
> >> > ... 25 more
> >> >
> >> > The exception is thrown in getFromUnicodeLE but i havent 
> encountered=20
> >> that=3D
> >> > =3D20
> >> > method usually being called to begin with. Any ideas on what to do? 
> I=
> > =20
> >> found=3D
> >> > =3D20
> >> > a bunch of similar bugs but nothing specifically referring to=3D20
> >> > getFromUnicodeLE or FontRecord.=3D20
> >> >
> >> > Thanks a bunch
> >> >
> >> > Muhammed
> >> > PS I went through the openoffice documentation but didnt find=20
> >> anything=3D20
> >> > specifically referencing a font record or what valid values its 
> data=20
> >> record=3D
> >> > =3D20
> >> > should contain @ the mentioned offset.
> >> >
> >> =20
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
> >> Mailing List: http://jakarta.apache.org/site/mail2.html#poi
> >> The Apache Jakarta Poi Project: http://jakarta.apache.org/poi/
> >> =20
> >>
> >
> 
>

Re: FontRecord problem

Posted by Muhammed Syyid <ms...@gmail.com>.
I found the bugzilla page but i'm not sure about which version to post it 
under. I just got HEAD from cvs. Looking at the build file, its got a 
property tag set @ "version.id" value="2.1", should I file it under
2.0final? Also about the bug itself, i've reproduced it in the current
stable
build as well the HEAD version i got. Sorry for being a pain but I can't 
submit the xls file, i've stripped all the data and can still recreate the 
problem but didn't get authorization to post it on the web. If one of you 
guys want to take a look i'll be more then happy to send it directly? Thanks

Muhammed

On 4/27/05, avik.sengupta@itellix.com <av...@itellix.com> wrote:
> 
> Sounds like a bug, thanks for the detailed investigation, could you please
> submit this to bugzilla, and and attach the offending sheet as well? this 
> will
> ensure that this issue does not drop thru the cracks.
> 
> I was wondering, however, why all sheets dont show this problem....ie, 
> what
> triggers the issue, is it non-ascii font name itself? I presume your sheet 
> is
> created by excel, rather than poi?
> 
> Regards
> -
> Avik
> 
> Quoting Muhammed Syyid <ms...@gmail.com>:
> 
> > Hi
> > An excel workbook of mine is causing an exception (mentioned below). 
> I've=
> > =20
> > tried tracing the code and it seems that a FontRecord is created with 
> byte=
> > =20
> > 14 > 0 which in turn causes=20
> > field_10_font_name_len > 0 causing unicode decoding code to be invoked 
> whic=
> > h=20
> > produces the exception itself. I've followed the codepath and the data 
> arra=
> > y=20
> > is filled directly from the inputstream, retrieving a +ve 124 for 
> data[14].=
> > =20
> >
> > Caused by: java.lang.IllegalArgumentException: Illegal length
> > at org.apache.poi.util.StringUtil.getFromUnicodeLE(StringUtil.java:78)
> > at org.apache.poi.hssf.record.FontRecord.fillFields(FontRecord.java:146)
> > at org.apache.poi.hssf.record.Record.fillFields(Record.java:91)
> > at org.apache.poi.hssf.record.Record.<init>(Record.java:55)
> > at org.apache.poi.hssf.record.FontRecord.<init>(FontRecord.java:88)
> > ... 25 more
> >
> > The exception is thrown in getFromUnicodeLE but i havent encountered 
> that=
> > =20
> > method usually being called to begin with. Any ideas on what to do? I 
> found=
> > =20
> > a bunch of similar bugs but nothing specifically referring to=20
> > getFromUnicodeLE or FontRecord.=20
> >
> > Thanks a bunch
> >
> > Muhammed
> > PS I went through the openoffice documentation but didnt find 
> anything=20
> > specifically referencing a font record or what valid values its data 
> record=
> > =20
> > should contain @ the mentioned offset.
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
> Mailing List: http://jakarta.apache.org/site/mail2.html#poi
> The Apache Jakarta Poi Project: http://jakarta.apache.org/poi/
> 
>

Re: FontRecord problem

Posted by av...@itellix.com.
Sounds like a bug, thanks for the detailed investigation, could you please
submit this to bugzilla, and and attach the offending sheet as well? this will
ensure that this issue does not drop thru the cracks.

I was wondering, however, why all sheets dont show this problem....ie, what
triggers the issue, is it non-ascii font name itself? I presume your sheet is
created by excel, rather than poi?

Regards
-
Avik

Quoting Muhammed Syyid <ms...@gmail.com>:

> Hi
> An excel workbook of mine is causing an exception (mentioned below). I've=
> =20
> tried tracing the code and it seems that a FontRecord is created with byte=
> =20
> 14 > 0 which in turn causes=20
> field_10_font_name_len > 0 causing unicode decoding code to be invoked whic=
> h=20
> produces the exception itself. I've followed the codepath and the data arra=
> y=20
> is filled directly from the inputstream, retrieving a +ve 124 for data[14].=
> =20
>
> Caused by: java.lang.IllegalArgumentException: Illegal length
> at org.apache.poi.util.StringUtil.getFromUnicodeLE(StringUtil.java:78)
> at org.apache.poi.hssf.record.FontRecord.fillFields(FontRecord.java:146)
> at org.apache.poi.hssf.record.Record.fillFields(Record.java:91)
> at org.apache.poi.hssf.record.Record.<init>(Record.java:55)
> at org.apache.poi.hssf.record.FontRecord.<init>(FontRecord.java:88)
> ... 25 more
>
> The exception is thrown in getFromUnicodeLE but i havent encountered that=
> =20
> method usually being called to begin with. Any ideas on what to do? I found=
> =20
> a bunch of similar bugs but nothing specifically referring to=20
> getFromUnicodeLE or FontRecord.=20
>
> Thanks a bunch
>
> Muhammed
> PS I went through the openoffice documentation but didnt find anything=20
> specifically referencing a font record or what valid values its data record=
> =20
> should contain @ the mentioned offset.
>



---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/


Re: FontRecord problem

Posted by an...@superlinksoftware.com.
Michael Zalewski wrote:
> I suppose field_10_font_name_len should be unsigned. (Meaning that it might
> need to be an int instead of a byte, or that when it is used as a parameter,

no...short -- not int.

---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/


RE: FontRecord problem

Posted by Michael Zalewski <za...@optonline.net>.
I suppose field_10_font_name_len should be unsigned. (Meaning that it might
need to be an int instead of a byte, or that when it is used as a parameter,
it should be padded instead of cast to an int). And FontRecord should check
the bit at data[15] instead of the whole byte. 

Byte 14 should have the length of the font name (in characters). If I ready
your message correctly, you see 124, which would mean that your font name is
124 characters long.

Byte 15 should be a flag indicating if the font name is expressed in Unicode
(0x00 = 8 bit, 0x01 = wide characters). There are other masks 0x04 if the
string is rich text, and 0x08 if the string contains Far East Phonetic
information. Could either of these situations apply? It seems that the POI
code assumes that if this value is not 0x00, it must be 0x01. If you have
some other value here, that could be the problem.

Byte 16 through 16 + n are the encoded font name (UTF-8 or Unicode LE,
depending on the options flag). If wide characters are used, n will be twice
the font length (at offset 14). Otherwise, for 8 bit characters, n will be
the same as the font length.

The error is caused if there are not enough bytes in the record to support
the string length, or if the string length is negative.

So can you give the values at 14, 15, ... and the size of the byte array? I
am guessing that you have a font name that is actually 124 characters long?
(Or I misread your message and the value at 14 is a negative byte, but
represents a font name length > 128 characters). (Or Microsoft has encoded
something special into the font name).

-----Original Message-----
From: Muhammed Syyid [mailto:msyyid@gmail.com] 
Sent: Wednesday, April 27, 2005 1:19 PM
To: poi-user@jakarta.apache.org
Subject: FontRecord problem

Hi
An excel workbook of mine is causing an exception (mentioned below). I've 
tried tracing the code and it seems that a FontRecord is created with byte 
14 > 0 which in turn causes 
field_10_font_name_len > 0 causing unicode decoding code to be invoked which

produces the exception itself. I've followed the codepath and the data array

is filled directly from the inputstream, retrieving a +ve 124 for data[14]. 

Caused by: java.lang.IllegalArgumentException: Illegal length
at org.apache.poi.util.StringUtil.getFromUnicodeLE(StringUtil.java:78)
at org.apache.poi.hssf.record.FontRecord.fillFields(FontRecord.java:146)
at org.apache.poi.hssf.record.Record.fillFields(Record.java:91)
at org.apache.poi.hssf.record.Record.<init>(Record.java:55)
at org.apache.poi.hssf.record.FontRecord.<init>(FontRecord.java:88)
... 25 more

The exception is thrown in getFromUnicodeLE but i havent encountered that 
method usually being called to begin with. Any ideas on what to do? I found 
a bunch of similar bugs but nothing specifically referring to 
getFromUnicodeLE or FontRecord. 

Thanks a bunch

Muhammed
PS I went through the openoffice documentation but didnt find anything 
specifically referencing a font record or what valid values its data record 
should contain @ the mentioned offset.


---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/