diff --git a/CHANGELOG.TXT b/CHANGELOG.TXT index 9ab9973..db7f7ae 100644 --- a/CHANGELOG.TXT +++ b/CHANGELOG.TXT @@ -1,3 +1,8 @@ +6.0.027 (2013-09-14) + - A bug in tcpdf_parser wen parsing hexadecimal strings was fixed. + - A bug in tcpdf_parser wen looking for statxref was fixed. + - A bug on RC4 encryption was fixed. + 6.0.026 (2013-09-14) - A bug in tcpdf_parser wen decoding streams was fixed. diff --git a/README.TXT b/README.TXT index 3e11b13..04272ca 100644 --- a/README.TXT +++ b/README.TXT @@ -8,7 +8,7 @@ http://sourceforge.net/donate/index.php?group_id=128076 ------------------------------------------------------------ Name: TCPDF -Version: 6.0.026 +Version: 6.0.027 Release date: 2013-09-14 Author: Nicola Asuni diff --git a/composer.json b/composer.json index fd691ba..d97c6b6 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "tecnick.com/tcpdf", - "version": "6.0.026", + "version": "6.0.027", "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 e46a147..783c152 100644 --- a/include/tcpdf_static.php +++ b/include/tcpdf_static.php @@ -1,9 +1,9 @@ * @package com.tecnick.tcpdf * @author Nicola Asuni - * @version 1.0.001 + * @version 1.0.002 */ /** @@ -46,7 +46,7 @@ * Static methods used by the TCPDF class. * @package com.tecnick.tcpdf * @brief PHP class for generating PDF documents without requiring external extensions. - * @version 1.0.001 + * @version 1.0.002 * @author Nicola Asuni - info@tecnick.com */ class TCPDF_STATIC { @@ -55,7 +55,7 @@ class TCPDF_STATIC { * Current TCPDF version. * @private static */ - private static $tcpdf_version = '6.0.026'; + private static $tcpdf_version = '6.0.027'; /** * String alias for total number of pages. @@ -1428,7 +1428,7 @@ class TCPDF_STATIC { * @public static */ public static function _RC4($key, $text, &$last_enc_key, &$last_enc_key_c) { - if (function_exists('mcrypt_decrypt') AND ($out = @mcrypt_decrypt(MCRYPT_ARCFOUR, $key, $text, MCRYPT_MODE_STREAM, ''))) { + if (function_exists('mcrypt_encrypt') AND ($out = @mcrypt_encrypt(MCRYPT_ARCFOUR, $key, $text, MCRYPT_MODE_STREAM, ''))) { // try to use mcrypt function if exist return $out; } diff --git a/tcpdf.php b/tcpdf.php index 800bfc3..59c16e4 100644 --- a/tcpdf.php +++ b/tcpdf.php @@ -1,7 +1,7 @@ * @package com.tecnick.tcpdf * @author Nicola Asuni - * @version 6.0.026 + * @version 6.0.027 */ // TCPDF configuration @@ -163,7 +163,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.026 + * @version 6.0.027 * @author Nicola Asuni - info@tecnick.com */ class TCPDF { diff --git a/tcpdf_parser.php b/tcpdf_parser.php index 161468f..396daef 100644 --- a/tcpdf_parser.php +++ b/tcpdf_parser.php @@ -1,7 +1,7 @@ * @package com.tecnick.tcpdf * @author Nicola Asuni - * @version 1.0.004 + * @version 1.0.005 */ // 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.003 + * @version 1.0.005 * @author Nicola Asuni - info@tecnick.com */ class TCPDF_PARSER { @@ -135,16 +135,17 @@ class TCPDF_PARSER { } $matches = array_pop($matches); $startxref = $matches[1]; + } elseif (strpos($this->pdfdata, 'xref', $offset) == $offset) { + // Already pointing at the xref table + $startxref = $offset; + } elseif (preg_match('/([0-9]+[\s][0-9]+[\s]obj)/i', $this->pdfdata, $matches, PREG_OFFSET_CAPTURE, $offset)) { + // Cross-Reference Stream object + $startxref = $offset; + } elseif (preg_match('/[\r\n]startxref[\s]*[\r\n]+([0-9]+)[\s]*[\r\n]+%%EOF/i', $this->pdfdata, $matches, PREG_OFFSET_CAPTURE, $offset)) { + // startxref found + $startxref = $matches[1][0]; } else { - if (preg_match('/([0-9]+[\s][0-9]+[\s]obj)/i', $this->pdfdata, $matches, PREG_OFFSET_CAPTURE, $offset)) { - // Cross-Reference Stream object - $startxref = $offset; - } elseif (preg_match('/[\r\n]startxref[\s]*[\r\n]+([0-9]+)[\s]*[\r\n]+%%EOF/i', $this->pdfdata, $matches, PREG_OFFSET_CAPTURE, $offset)) { - // startxref found - $startxref = $matches[1][0]; - } else { - $this->Error('Unable to find startxref'); - } + $this->Error('Unable to find startxref'); } // check xref position if (strpos($this->pdfdata, 'xref', $startxref) == $startxref) { @@ -209,6 +210,7 @@ class TCPDF_PARSER { } if (preg_match('/Encrypt[\s]+([0-9]+)[\s]+([0-9]+)[\s]+R/i', $trailer_data, $matches) > 0) { $xref['trailer']['encrypt'] = intval($matches[1]).'_'.intval($matches[2]); + $this->Error('Encrypted documents are not supported!'); } if (preg_match('/Info[\s]+([0-9]+)[\s]+([0-9]+)[\s]+R/i', $trailer_data, $matches) > 0) { $xref['trailer']['info'] = intval($matches[1]).'_'.intval($matches[2]); @@ -447,7 +449,7 @@ class TCPDF_PARSER { // 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 += strspn($this->pdfdata, "\x00\x09\x0a\x0c\x0d\x20", $offset); // get first char - $char = $this->pdfdata{$offset}; + $char = $this->pdfdata[$offset]; // get object type switch ($char) { case '%': { // \x25 PERCENT SIGN @@ -545,8 +547,9 @@ class TCPDF_PARSER { // hexadecimal string object $objtype = $char; ++$offset; - if (($char == '<') AND (preg_match('/^([0-9A-Fa-f]+)[>]/iU', substr($this->pdfdata, $offset), $matches) == 1)) { - $objval = $matches[1]; + if (($char == '<') AND (preg_match('/^([0-9A-Fa-f\x09\x0a\x0c\x0d\x20]+)>/iU', substr($this->pdfdata, $offset), $matches) == 1)) { + // remove white space characters + $objval = strtr($matches[1], "\x09\x0a\x0c\x0d\x20", ''); $offset += strlen($matches[0]); } } @@ -636,7 +639,7 @@ class TCPDF_PARSER { $i = 0; // object main index do { // get element - $element = $this->getRawObject($offset); + $element = $this->getRawObject($offset); print_r($element);//DEBUG $offset = $element[2]; // decode stream using stream's dictionary information if ($decoding AND ($element[0] == 'stream') AND (isset($objdata[($i - 1)][0])) AND ($objdata[($i - 1)][0] == '<<')) {