From: <ed...@mx...> - 2003-02-04 13:14:50
|
edwin 03/02/04 08:22:56 Modified: openpgp/src/cryptix/openpgp/provider PGPMessageFactory.java Log: Fix errors when parsing armoured data surrounded by other data. Revision Changes Path 1.3 +18 -8 projects/openpgp/src/cryptix/openpgp/provider/PGPMessageFactory.java Index: PGPMessageFactory.java =================================================================== RCS file: /home/cryptix-cvs/cvsroot/projects/openpgp/src/cryptix/openpgp/provider/PGPMessageFactory.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- PGPMessageFactory.java 27 Dec 2001 15:01:31 -0000 1.2 +++ PGPMessageFactory.java 4 Feb 2003 13:22:56 -0000 1.3 @@ -1,4 +1,4 @@ -/* $Id: PGPMessageFactory.java,v 1.2 2001/12/27 15:01:31 edwin Exp $ +/* $Id: PGPMessageFactory.java,v 1.3 2003/02/04 13:22:56 edwin Exp $ * * Copyright (C) 2001 The Cryptix Foundation Limited. * All rights reserved. @@ -53,7 +53,7 @@ * Service provider interface for MessageFactory * * @author Edwin Woudt <ed...@cr...> - * @version $Revision: 1.2 $ + * @version $Revision: 1.3 $ */ public class PGPMessageFactory extends MessageFactorySpi { @@ -88,20 +88,26 @@ PGPArmoury armoury; Vector result = new Vector(); - while (br.ready()) { + String line = br.readLine(); - String line = br.readLine(); - buf.append(line); - buf.append(CRLF); + while (br.ready()) { - if ((line.startsWith("-----BEGIN")) && (br.ready())) { + if (line.startsWith("-----BEGIN")) { + buf.append(line); + buf.append(CRLF); + while (! line.startsWith("-----END")) { line = br.readLine(); buf.append(line); buf.append(CRLF); } + + if (br.ready()) + line = br.readLine(); + else + line = ""; try { @@ -156,15 +162,19 @@ while ((! line.startsWith("-----BEGIN")) && (br.ready())) { - line = br.readLine(); buf.append(line); buf.append(CRLF); + line = br.readLine(); } PGPLiteralDataPacket ldp = new PGPLiteralDataPacket(); ldp.setData(buf.toString()); PGPLiteralMessageImpl lm = new PGPLiteralMessageImpl(ldp); + + result.add(lm); } + + buf = new StringBuffer(); } return result; |