pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gbaill...@apache.org
Subject svn commit: r1429210 - /pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/parser/PreflightParser.java
Date Sat, 05 Jan 2013 07:00:35 GMT
Author: gbailleul
Date: Sat Jan  5 07:00:35 2013
New Revision: 1429210

URL: http://svn.apache.org/viewvc?rev=1429210&view=rev
Log:
PDFBOX-1477 : applyed patch PDFBOX1477.patch

Modified:
    pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/parser/PreflightParser.java

Modified: pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/parser/PreflightParser.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/parser/PreflightParser.java?rev=1429210&r1=1429209&r2=1429210&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/parser/PreflightParser.java
(original)
+++ pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/parser/PreflightParser.java
Sat Jan  5 07:00:35 2013
@@ -21,11 +21,13 @@
 
 package org.apache.pdfbox.preflight.parser;
 
-import static org.apache.pdfbox.preflight.PreflightConstants.*;
+import static org.apache.pdfbox.preflight.PreflightConstants.ERROR_SYNTAX_ARRAY_TOO_LONG;
 import static org.apache.pdfbox.preflight.PreflightConstants.ERROR_SYNTAX_CROSS_REF;
 import static org.apache.pdfbox.preflight.PreflightConstants.ERROR_SYNTAX_HEXA_STRING_EVEN_NUMBER;
 import static org.apache.pdfbox.preflight.PreflightConstants.ERROR_SYNTAX_HEXA_STRING_INVALID;
 import static org.apache.pdfbox.preflight.PreflightConstants.ERROR_SYNTAX_HEXA_STRING_TOO_LONG;
+import static org.apache.pdfbox.preflight.PreflightConstants.ERROR_SYNTAX_INVALID_OFFSET;
+import static org.apache.pdfbox.preflight.PreflightConstants.ERROR_SYNTAX_MISSING_OFFSET;
 import static org.apache.pdfbox.preflight.PreflightConstants.ERROR_SYNTAX_NAME_TOO_LONG;
 import static org.apache.pdfbox.preflight.PreflightConstants.ERROR_SYNTAX_NUMERIC_RANGE;
 import static org.apache.pdfbox.preflight.PreflightConstants.ERROR_SYNTAX_OBJ_DELIMITER;
@@ -253,16 +255,17 @@ public class PreflightParser extends Non
 	protected void checkPdfHeader() {
 		BufferedReader reader = null;
 		try {
-			reader = new BufferedReader(new InputStreamReader(new FileInputStream(getPdfFile()), "ISO-8859-1"));
+			reader = new BufferedReader(new InputStreamReader(new FileInputStream(getPdfFile()), encoding));
 			String firstLine = reader.readLine();
 			if (firstLine == null || (firstLine != null && !firstLine.matches("%PDF-1\\.[1-9]")))
{
 				addValidationError(new ValidationError(PreflightConstants.ERROR_SYNTAX_HEADER, "First
line must match %PDF-1.\\d"));	
 			}
 
 			String secondLine = reader.readLine(); 
-			if (secondLine != null && secondLine.getBytes().length >= 5) {
-				for (int i = 0; i < secondLine.getBytes().length; ++i ) {
-					byte b = secondLine.getBytes()[i]; 
+			byte[] secondLineAsBytes = secondLine.getBytes(encoding);
+			if (secondLine != null && secondLineAsBytes.length >= 5) {
+				for (int i = 0; i < secondLineAsBytes.length; ++i ) {
+					byte b = secondLineAsBytes[i]; 
 					if (i == 0 && ((char)b != '%')) {
 						addValidationError(new ValidationError(PreflightConstants.ERROR_SYNTAX_HEADER, "Second
line must contains at least 4 bytes greater than 127"));
 						break;



Mime
View raw message