xmlgraphics-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 51039] New: Crash of due to a NumberFormatException in XMPSchemaAdapter (problem of GMT parsing)
Date Thu, 07 Apr 2011 18:18:59 GMT
https://issues.apache.org/bugzilla/show_bug.cgi?id=51039

           Summary: Crash of  due to a NumberFormatException in
                    XMPSchemaAdapter (problem of GMT parsing)
           Product: XMLGraphicsCommons
           Version: 1.4
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: blocker
          Priority: P2
         Component: XMP
        AssignedTo: general@xmlgraphics.apache.org
        ReportedBy: f.barbera@hotmail.fr


Hi there !

I think there is an issue in the method formatISO8601Date of the class
org.apache.xmlgraphics.xmp.XMPSchemaAdapter

When you have a negative GMT indication and when the negative number is less or
equal to -10 then there is a problem.

The piece of code:

if (zoneOffsetHours > 0) { 
sb.append('+');
} else {
sb.append('-'); 
} 

if (zoneOffsetHours < 10) {
         sb.append('0'); 
}

If I have zoneOffsetHours = -10 I will have zoneOffsetHours < 10 true (-10 <
10) so I will have sb concatenated with “-010” and not with “-10”.

The result is : 2011-04-07T08:12:11-010:00

I think we should have 2011-04-07T08:12:11-10:00 (no zero before the -10).

It causes a NumberFormatException in my case, if I use FOP. the error is in the
parseISO8601Date method of the same class : 

The line that crashes is the following :

offset += Integer.parseInt(timeZonePart.substring(4, 6));

The result of timeZonePart.substring(4, 6) is :0 and not 00 as it should be.

Exception in thread "main" java.lang.NumberFormatException: For input string:
":0"
    at
java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
    at java.lang.Integer.parseInt(Integer.java:449)
    at java.lang.Integer.parseInt(Integer.java:499)
    at
org.apache.xmlgraphics.xmp.XMPSchemaAdapter.parseISO8601Date(XMPSchemaAdapter.java:236)
    at
org.apache.xmlgraphics.xmp.XMPSchemaAdapter.getDateValue(XMPSchemaAdapter.java:282)
    at
org.apache.xmlgraphics.xmp.schemas.XMPBasicAdapter.getMetadataDate(XMPBasicAdapter.java:170)
    at
org.apache.fop.render.intermediate.IFRenderer.createDefaultDocumentMetadata(IFRenderer.java:549)
    at
org.apache.fop.render.intermediate.IFRenderer.startPageSequence(IFRenderer.java:500)
    at
org.apache.fop.area.RenderPagesModel.startPageSequence(RenderPagesModel.java:89)
    at
org.apache.fop.layoutmgr.PageSequenceLayoutManager.activateLayout(PageSequenceLayoutManager.java:98)
    at
org.apache.fop.area.AreaTreeHandler.endPageSequence(AreaTreeHandler.java:238)
    at
org.apache.fop.fo.pagination.PageSequence.endOfNode(PageSequence.java:120)
    at
org.apache.fop.fo.FOTreeBuilder$MainFOHandler.endElement(FOTreeBuilder.java:349)
    at org.apache.fop.fo.FOTreeBuilder.endElement(FOTreeBuilder.java:177)
    at
org.apache.xalan.transformer.TransformerIdentityImpl.endElement(TransformerIdentityImpl.java:1102)
    at
com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:601)
    at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(XMLDocumentFragmentScannerImpl.java:1782)
    at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2938)
    at
com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:648)
    at
com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:140)
    at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:511)
    at
com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:808)
    at
com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
    at
com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119)
    at
com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205)
    at
org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:485)
    at
com.micropol.micronix.engine.tools.pdf.PdfCreator.convertFO2PDF(PdfCreator.java:95)
    at
com.micropol.micronix.engine.tools.pdf.PdfCreator.main(PdfCreator.java:121)

As a result, each part of the word that has a GMT -10,-11,-12,-13 (Tonga)
cannot use FOP 1.0. It is the case for many Pacific islands (I'm in French
Polynesia).

I think that the good test would be :

if (Math.abs(zoneOffsetHours) < 10) {
         sb.append('0'); 
}

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: general-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: general-help@xmlgraphics.apache.org


Mime
View raw message