diff --git a/CHANGELOG.TXT b/CHANGELOG.TXT index 7d7272c..0d18b36 100644 --- a/CHANGELOG.TXT +++ b/CHANGELOG.TXT @@ -1,3 +1,6 @@ +6.0.034 (2013-09-24) + - Bug #839 "Error in xref parsing in mixed newline chars" was fixed. + 6.0.033 (2013-09-23) - Bug fix related to PNG image transparency using GD library. diff --git a/README.TXT b/README.TXT index 130a3d8..311089e 100644 --- a/README.TXT +++ b/README.TXT @@ -8,8 +8,8 @@ http://sourceforge.net/donate/index.php?group_id=128076 ------------------------------------------------------------ Name: TCPDF -Version: 6.0.033 -Release date: 2013-09-23 +Version: 6.0.034 +Release date: 2013-09-24 Author: Nicola Asuni Copyright (c) 2002-2013: diff --git a/composer.json b/composer.json index f728b3a..39d2d8b 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "tecnick.com/tcpdf", - "version": "6.0.033", + "version": "6.0.034", "homepage": "http://www.tcpdf.org/", "type": "library", "description": "TCPDF is a PHP class for generating PDF documents.", diff --git a/include/tcpdf_static.php b/include/tcpdf_static.php index c30b97d..5c3bc12 100644 --- a/include/tcpdf_static.php +++ b/include/tcpdf_static.php @@ -55,7 +55,7 @@ class TCPDF_STATIC { * Current TCPDF version. * @private static */ - private static $tcpdf_version = '6.0.033'; + private static $tcpdf_version = '6.0.034'; /** * String alias for total number of pages. diff --git a/tcpdf.php b/tcpdf.php index 9461842..0f942cd 100644 --- a/tcpdf.php +++ b/tcpdf.php @@ -1,9 +1,9 @@ * @package com.tecnick.tcpdf * @author Nicola Asuni - * @version 6.0.033 + * @version 6.0.034 */ // TCPDF configuration @@ -128,7 +128,7 @@ require_once(dirname(__FILE__).'/include/tcpdf_static.php'); * TCPDF project (http://www.tcpdf.org) has been originally derived in 2002 from the Public Domain FPDF class by Olivier Plathey (http://www.fpdf.org), but now is almost entirely rewritten.
* @package com.tecnick.tcpdf * @brief PHP class for generating PDF documents without requiring external extensions. - * @version 6.0.033 + * @version 6.0.034 * @author Nicola Asuni - info@tecnick.com */ class TCPDF { diff --git a/tcpdf_parser.php b/tcpdf_parser.php index d3d8d45..00bd3e9 100644 --- a/tcpdf_parser.php +++ b/tcpdf_parser.php @@ -1,9 +1,9 @@ * @package com.tecnick.tcpdf * @author Nicola Asuni - * @version 1.0.008 + * @version 1.0.009 */ // include class for decoding filters @@ -48,7 +48,7 @@ require_once(dirname(__FILE__).'/include/tcpdf_filters.php'); * This is a PHP class for parsing PDF documents.
* @package com.tecnick.tcpdf * @brief This is a PHP class for parsing PDF documents.. - * @version 1.0.005 + * @version 1.0.009 * @author Nicola Asuni - info@tecnick.com */ class TCPDF_PARSER { @@ -188,20 +188,25 @@ class TCPDF_PARSER { /** * Decode the Cross-Reference section - * @param $startxref (int) Offset at which the xref section starts. + * @param $startxref (int) Offset at which the xref section starts (position of the 'xref' keyword). * @param $xref (array) Previous xref array (if any). * @return Array containing xref and trailer data. * @protected * @since 1.0.000 (2011-06-20) */ protected function decodeXref($startxref, $xref=array()) { - // extract xref data (object indexes and offsets) - $xoffset = $startxref + 5; + $startxref += 4; // 4 is the lenght of the word 'xref' + // skip initial white space chars: \x00 null (NUL), \x09 horizontal tab (HT), \x0A line feed (LF), \x0C form feed (FF), \x0D carriage return (CR), \x20 space (SP) + $offset = $startxref + strspn($this->pdfdata, "\x00\x09\x0a\x0c\x0d\x20", $startxref); // initialize object number $obj_num = 0; - $offset = $xoffset; - while (preg_match('/^([0-9]+)[\s]([0-9]+)[\s]?([nf]?)/im', $this->pdfdata, $matches, PREG_OFFSET_CAPTURE, $offset) > 0) { - $offset = (strlen($matches[0][0]) + $matches[0][1]); + // search for cross-reference entries or subsection + while (preg_match('/([0-9]+)[\x20]([0-9]+)[\x20]?([nf]?)(\r\n|[\x20]?[\r\n])/', $this->pdfdata, $matches, PREG_OFFSET_CAPTURE, $offset) > 0) { + if ($matches[0][1] != $offset) { + // we are on another section + break; + } + $offset += strlen($matches[0][0]); if ($matches[3][0] == 'n') { // create unique object index: [object number]_[generation number] $index = $obj_num.'_'.intval($matches[2][0]); @@ -211,17 +216,15 @@ class TCPDF_PARSER { $xref['xref'][$index] = intval($matches[1][0]); } ++$obj_num; - $offset += 2; } elseif ($matches[3][0] == 'f') { ++$obj_num; - $offset += 2; } else { // object number (index) $obj_num = intval($matches[1][0]); } } // get trailer data - if (preg_match('/trailer[\s]*<<(.*)>>[\s]*[\r\n]+startxref[\s]*[\r\n]+/isU', $this->pdfdata, $matches, PREG_OFFSET_CAPTURE, $xoffset) > 0) { + if (preg_match('/trailer[\s]*<<(.*)>>[\s]*[\r\n]+startxref[\s]*[\r\n]+/isU', $this->pdfdata, $matches, PREG_OFFSET_CAPTURE, $offset) > 0) { $trailer_data = $matches[1][0]; if (!isset($xref['trailer']) OR empty($xref['trailer'])) { // get only the last updated version