6.0.021 (2013-07-18)

- The bug caused by the preg_split function on some PHP 5.2.x versions was fixed.
This commit is contained in:
nicolaasuni 2013-07-18 20:45:24 +01:00
parent 57959d4027
commit 94bfcb9bb4
6 changed files with 50 additions and 16 deletions

View File

@ -1,3 +1,6 @@
6.0.021 (2013-07-18)
- The bug caused by the preg_split function on some PHP 5.2.x versions was fixed.
6.0.020 (2013-06-04)
- The method addTTFfont() was fixed (Bug item #813 Undefined offset).

View File

@ -8,8 +8,8 @@ http://sourceforge.net/donate/index.php?group_id=128076
------------------------------------------------------------
Name: TCPDF
Version: 6.0.020
Release date: 2013-06-04
Version: 6.0.021
Release date: 2013-07-18
Author: Nicola Asuni
Copyright (c) 2002-2013:

View File

@ -1,6 +1,6 @@
{
"name": "tecnick.com/tcpdf",
"version": "6.0.020",
"version": "6.0.021",
"homepage": "http://www.tcpdf.org/",
"type": "library",
"description": "TCPDF is a PHP class for generating PDF documents.",

View File

@ -1,9 +1,9 @@
<?php
//============================================================+
// File name : tcpdf_fonts.php
// Version : 1.0.007
// Version : 1.0.008
// Begin : 2008-01-01
// Last Update : 2013-06-04
// Last Update : 2013-07-18
// Author : Nicola Asuni - Tecnick.com LTD - www.tecnick.com - info@tecnick.com
// License : GNU-LGPL v3 (http://www.gnu.org/copyleft/lesser.html)
// -------------------------------------------------------------------
@ -42,7 +42,7 @@
* @class TCPDF_FONTS
* Font methods for TCPDF library.
* @package com.tecnick.tcpdf
* @version 1.0.007
* @version 1.0.008
* @author Nicola Asuni - info@tecnick.com
*/
class TCPDF_FONTS {
@ -1815,7 +1815,7 @@ class TCPDF_FONTS {
// characters.
return 0xFFFD; // use replacement character
} else {
return $char; // add char to array
return $char;
}
}
} else {
@ -1839,7 +1839,7 @@ class TCPDF_FONTS {
public static function UTF8StringToArray($str, $isunicode=true, &$currentfont) {
if ($isunicode) {
// requires PCRE unicode support turned on
$chars = preg_split("//u", $str, -1, PREG_SPLIT_NO_EMPTY);
$chars = TCPDF_STATIC::pregSplit('//','u', $str, -1, PREG_SPLIT_NO_EMPTY);
$carr = array_map(array('self', 'uniord'), $chars);
} else {
$chars = str_split($str);

View File

@ -55,7 +55,7 @@ class TCPDF_STATIC {
* Current TCPDF version.
* @private static
*/
private static $tcpdf_version = '6.0.020';
private static $tcpdf_version = '6.0.021';
/**
* String alias for total number of pages.
@ -2723,6 +2723,37 @@ class TCPDF_STATIC {
return $angle;
}
/**
* Split string by a regular expression.
* This is a wrapper for the preg_split function to avoid the bug: https://bugs.php.net/bug.php?id=45850
* @param $pattern (string) The regular expression pattern to search for without the modifiers, as a string.
* @param $modifiers (string) The modifiers part of the pattern,
* @param $subject (string) The input string.
* @param $limit (int) If specified, then only substrings up to limit are returned with the rest of the string being placed in the last substring. A limit of -1, 0 or NULL means "no limit" and, as is standard across PHP, you can use NULL to skip to the flags parameter.
* @param $flags (int) The flags as specified on the preg_split PHP function.
* @return Returns an array containing substrings of subject split along boundaries matched by pattern.modifier
* @author Nicola Asuni
* @since 6.0.021
* @public static
*/
public static function pregSplit($pattern, $modifiers, $subject, $limit=NULL, $flags=NULL) {
// the bug only happens on PHP 5.2 when using the u modifier
if ((strpos($modifiers, 'u') === FALSE) OR (count(preg_split('//u', "\n\t", -1, PREG_SPLIT_NO_EMPTY)) == 2)) {
return preg_split($pattern.$modifiers, $subject, $limit, $flags);
}
// preg_split is bugged - try alternative solution
$ret = array();
while (($nl = strpos($subject, "\n")) !== FALSE) {
$ret = array_merge($ret, preg_split($pattern.$modifiers, substr($subject, 0, $nl), $limit, $flags));
$ret[] = "\n";
$subject = substr($subject, ($nl + 1));
}
if (!empty($subject)) {
$ret = array_merge($ret, preg_split($pattern.$modifiers, $subject, $limit, $flags));
}
return $ret;
}
} // END OF TCPDF_STATIC CLASS
//============================================================+

View File

@ -1,9 +1,9 @@
<?php
//============================================================+
// File name : tcpdf.php
// Version : 6.0.020
// Version : 6.0.021
// Begin : 2002-08-03
// Last Update : 2013-06-04
// Last Update : 2013-07-18
// Author : Nicola Asuni - Tecnick.com LTD - www.tecnick.com - info@tecnick.com
// License : GNU-LGPL v3 (http://www.gnu.org/copyleft/lesser.html)
// -------------------------------------------------------------------
@ -139,7 +139,7 @@
* Tools to encode your unicode fonts are on fonts/utils directory.</p>
* @package com.tecnick.tcpdf
* @author Nicola Asuni
* @version 6.0.020
* @version 6.0.021
*/
// 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.<br>
* @package com.tecnick.tcpdf
* @brief PHP class for generating PDF documents without requiring external extensions.
* @version 6.0.020
* @version 6.0.021
* @author Nicola Asuni - info@tecnick.com
*/
class TCPDF {
@ -6494,7 +6494,7 @@ class TCPDF {
}
// check the length of the next string
$strrest = TCPDF_FONTS::UniArrSubString($uchars, ($sep + $endspace));
$nextstr = preg_split('/'.$this->re_space['p'].'/'.$this->re_space['m'], $this->stringTrim($strrest));
$nextstr = TCPDF_STATIC::pregSplit('/'.$this->re_space['p'].'/', $this->re_space['m'], $this->stringTrim($strrest));
if (isset($nextstr[0]) AND ($this->GetStringWidth($nextstr[0]) > $pw)) {
// truncate the word because do not fit on a full page width
$tmpstr = TCPDF_FONTS::UniArrSubString($uchars, $j, $i);
@ -18149,7 +18149,7 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value:
$tmp_fontsize = isset($dom[$nkey]['fontsize']) ? $dom[$nkey]['fontsize'] : $this->FontSizePt;
$same_textdir = ($dom[$nkey]['dir'] == $dom[$key]['dir']);
} else {
$nextstr = preg_split('/'.$this->re_space['p'].'+/'.$this->re_space['m'], $dom[$nkey]['value']);
$nextstr = TCPDF_STATIC::pregSplit('/'.$this->re_space['p'].'+/', $this->re_space['m'], $dom[$nkey]['value']);
if (isset($nextstr[0]) AND $same_textdir) {
$wadj += $this->GetStringWidth($nextstr[0], $tmp_fontname, $tmp_fontstyle, $tmp_fontsize);
if (isset($nextstr[1])) {
@ -18162,7 +18162,7 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value:
}
if (($wadj > 0) AND (($strlinelen + $wadj) >= $cwa)) {
$wadj = 0;
$nextstr = preg_split('/'.$this->re_space['p'].'/'.$this->re_space['m'], $dom[$key]['value']);
$nextstr = TCPDF_STATIC::pregSplit('/'.$this->re_space['p'].'/', $this->re_space['m'], $dom[$key]['value']);
$numblks = count($nextstr);
if ($numblks > 1) {
// try to split on blank spaces