MDL-64794 tcpdf: Bump to tcpdf 6.2.26

This commit is contained in:
Eloy Lafuente (stronk7) 2019-05-06 01:57:01 +02:00
parent 29c395187f
commit 46855d025e
11 changed files with 390 additions and 235 deletions

View file

@ -1,3 +1,18 @@
6.2.25
- Fix support for image URLs.
6.2.24
- Support remote urls when checking if file exists.
6.2.23
- Simplify file_exists function.
6.2.22
- Fix for security vulnerability: Using the phar:// wrapper it was possible to trigger the unserialization of user provided data.
6.2.19
- Merge various fixes for PHP 7.3 compatibility and security.
6.2.13 (2016-06-10) 6.2.13 (2016-06-10)
- IMPORTANT: A new version of this library is under development at https://github.com/tecnickcom/tc-lib-pdf and as a consequence this version will not receive any additional development or support. This version should be considered obsolete, new projects should use the new version as soon it will become stable. - IMPORTANT: A new version of this library is under development at https://github.com/tecnickcom/tc-lib-pdf and as a consequence this version will not receive any additional development or support. This version should be considered obsolete, new projects should use the new version as soon it will become stable.

84
lib/tcpdf/README.md Normal file
View file

@ -0,0 +1,84 @@
# TCPDF
*PHP PDF Library*
[![Donate via PayPal](https://img.shields.io/badge/donate-paypal-87ceeb.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&currency_code=GBP&business=paypal@tecnick.com&item_name=donation%20for%20TCPDF%20project)
*Please consider supporting this project by making a donation via [PayPal](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&currency_code=GBP&business=paypal@tecnick.com&item_name=donation%20for%20TCPDF%20project)*
* **category** Library
* **author** Nicola Asuni <info@tecnick.com>
* **copyright** 2002-2018 Nicola Asuni - Tecnick.com LTD
* **license** http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* **link** http://www.tcpdf.org
* **source** https://github.com/tecnickcom/TCPDF
## IMPORTANT
A new version of this library is under development at https://github.com/tecnickcom/tc-lib-pdf and as a consequence this version will not receive any additional development or support.
This version should be considered obsolete, new projects should use the new version as soon it will become stable.
## Description
PHP library for generating PDF documents on-the-fly.
### Main Features:
* no external libraries are required for the basic functions;
* all standard page formats, custom page formats, custom margins and units of measure;
* UTF-8 Unicode and Right-To-Left languages;
* TrueTypeUnicode, OpenTypeUnicode v1, TrueType, OpenType v1, Type1 and CID-0 fonts;
* font subsetting;
* methods to publish some XHTML + CSS code, Javascript and Forms;
* images, graphic (geometric figures) and transformation methods;
* supports JPEG, PNG and SVG images natively, all images supported by GD (GD, GD2, GD2PART, GIF, JPEG, PNG, BMP, XBM, XPM) and all images supported via ImagMagick (http://www.imagemagick.org/script/formats.php)
* 1D and 2D barcodes: CODE 39, ANSI MH10.8M-1983, USD-3, 3 of 9, CODE 93, USS-93, Standard 2 of 5, Interleaved 2 of 5, CODE 128 A/B/C, 2 and 5 Digits UPC-Based Extension, EAN 8, EAN 13, UPC-A, UPC-E, MSI, POSTNET, PLANET, RMS4CC (Royal Mail 4-state Customer Code), CBC (Customer Bar Code), KIX (Klant index - Customer index), Intelligent Mail Barcode, Onecode, USPS-B-3200, CODABAR, CODE 11, PHARMACODE, PHARMACODE TWO-TRACKS, Datamatrix, QR-Code, PDF417;
* JPEG and PNG ICC profiles, Grayscale, RGB, CMYK, Spot Colors and Transparencies;
* automatic page header and footer management;
* document encryption up to 256 bit and digital signature certifications;
* transactions to UNDO commands;
* PDF annotations, including links, text and file attachments;
* text rendering modes (fill, stroke and clipping);
* multiple columns mode;
* no-write page regions;
* bookmarks, named destinations and table of content;
* text hyphenation;
* text stretching and spacing (tracking);
* automatic page break, line break and text alignments including justification;
* automatic page numbering and page groups;
* move and delete pages;
* page compression (requires php-zlib extension);
* XOBject Templates;
* Layers and object visibility.
* PDF/A-1b support.
### Third party fonts:
This library may include third party font files released with different licenses.
All the PHP files on the fonts directory are subject to the general TCPDF license (GNU-LGPLv3),
they do not contain any binary data but just a description of the general properties of a particular font.
These files can be also generated on the fly using the font utilities and TCPDF methods.
All the original binary TTF font files have been renamed for compatibility with TCPDF and compressed using the gzcompress PHP function that uses the ZLIB data format (.z files).
The binary files (.z) that begins with the prefix "free" have been extracted from the GNU FreeFont collection (GNU-GPLv3).
The binary files (.z) that begins with the prefix "pdfa" have been derived from the GNU FreeFont, so they are subject to the same license.
For the details of Copyright, License and other information, please check the files inside the directory fonts/freefont-20120503
Link : http://www.gnu.org/software/freefont/
The binary files (.z) that begins with the prefix "dejavu" have been extracted from the DejaVu fonts 2.33 (Bitstream) collection.
For the details of Copyright, License and other information, please check the files inside the directory fonts/dejavu-fonts-ttf-2.33
Link : http://dejavu-fonts.org
The binary files (.z) that begins with the prefix "ae" have been extracted from the Arabeyes.org collection (GNU-GPLv2).
Link : http://projects.arabeyes.org/
### ICC profile:
TCPDF includes the sRGB.icc profile from the icc-profiles-free Debian package:
https://packages.debian.org/source/stable/icc-profiles-free
## Developer(s) Contact
* Nicola Asuni <info@tecnick.com>

View file

@ -1,16 +1,24 @@
{ {
"name": "tecnickcom/tcpdf", "name": "tecnickcom/tcpdf",
"version": "6.2.13", "version": "6.2.26",
"homepage": "http://www.tcpdf.org/", "homepage": "http://www.tcpdf.org/",
"type": "library", "type": "library",
"description": "TCPDF is a PHP class for generating PDF documents and barcodes.", "description": "TCPDF is a PHP class for generating PDF documents and barcodes.",
"keywords": ["PDF","tcpdf","PDFD32000-2008","qrcode","datamatrix","pdf417","barcodes"], "keywords": [
"license": "LGPLv3", "PDF",
"tcpdf",
"PDFD32000-2008",
"qrcode",
"datamatrix",
"pdf417",
"barcodes"
],
"license": "LGPL-3.0",
"authors": [ "authors": [
{ {
"name": "Nicola Asuni", "name": "Nicola Asuni",
"email": "info@tecnick.com", "email": "info@tecnick.com",
"homepage": "http://nicolaasuni.tecnick.com" "role": "lead"
} }
], ],
"require": { "require": {

View file

@ -740,16 +740,6 @@ class PDF417 {
* @protected * @protected
*/ */
protected function getErrorCorrectionLevel($ecl, $numcw) { protected function getErrorCorrectionLevel($ecl, $numcw) {
// get maximum correction level
$maxecl = 8; // starting error level
$maxerrsize = (928 - $numcw); // available codewords for error
while ($maxecl > 0) {
$errsize = (2 << $ecl);
if ($maxerrsize >= $errsize) {
break;
}
--$maxecl;
}
// check for automatic levels // check for automatic levels
if (($ecl < 0) OR ($ecl > 8)) { if (($ecl < 0) OR ($ecl > 8)) {
if ($numcw < 41) { if ($numcw < 41) {
@ -764,6 +754,16 @@ class PDF417 {
$ecl = $maxecl; $ecl = $maxecl;
} }
} }
// get maximum correction level
$maxecl = 8; // starting error level
$maxerrsize = (928 - $numcw); // available codewords for error
while ($maxecl > 0) {
$errsize = (2 << $ecl);
if ($maxerrsize >= $errsize) {
break;
}
--$maxecl;
}
if ($ecl > $maxecl) { if ($ecl > $maxecl) {
$ecl = $maxecl; $ecl = $maxecl;
} }

Binary file not shown.

View file

@ -70,7 +70,7 @@ class TCPDF_FONTS {
* @public static * @public static
*/ */
public static function addTTFfont($fontfile, $fonttype='', $enc='', $flags=32, $outpath='', $platid=3, $encid=1, $addcbbox=false, $link=false) { public static function addTTFfont($fontfile, $fonttype='', $enc='', $flags=32, $outpath='', $platid=3, $encid=1, $addcbbox=false, $link=false) {
if (!file_exists($fontfile)) { if (!TCPDF_STATIC::file_exists($fontfile)) {
// Could not find file // Could not find file
return false; return false;
} }
@ -95,7 +95,7 @@ class TCPDF_FONTS {
$outpath = self::_getfontpath(); $outpath = self::_getfontpath();
} }
// check if this font already exist // check if this font already exist
if (@file_exists($outpath.$font_name.'.php')) { if (@TCPDF_STATIC::file_exists($outpath.$font_name.'.php')) {
// this font already exist (delete it from fonts folder to rebuild it) // this font already exist (delete it from fonts folder to rebuild it)
return $font_name; return $font_name;
} }
@ -665,7 +665,7 @@ class TCPDF_FONTS {
$glyphIdArray[$k] = TCPDF_STATIC::_getUSHORT($font, $offset); $glyphIdArray[$k] = TCPDF_STATIC::_getUSHORT($font, $offset);
$offset += 2; $offset += 2;
} }
for ($k = 0; $k < $segCount; ++$k) { for ($k = 0; $k < $segCount - 1; ++$k) {
for ($c = $startCount[$k]; $c <= $endCount[$k]; ++$c) { for ($c = $startCount[$k]; $c <= $endCount[$k]; ++$c) {
if ($idRangeOffset[$k] == 0) { if ($idRangeOffset[$k] == 0) {
$g = ($idDelta[$k] + $c) % 65536; $g = ($idDelta[$k] + $c) % 65536;
@ -1543,11 +1543,11 @@ class TCPDF_FONTS {
public static function getFontFullPath($file, $fontdir=false) { public static function getFontFullPath($file, $fontdir=false) {
$fontfile = ''; $fontfile = '';
// search files on various directories // search files on various directories
if (($fontdir !== false) AND @file_exists($fontdir.$file)) { if (($fontdir !== false) AND @TCPDF_STATIC::file_exists($fontdir.$file)) {
$fontfile = $fontdir.$file; $fontfile = $fontdir.$file;
} elseif (@file_exists(self::_getfontpath().$file)) { } elseif (@TCPDF_STATIC::file_exists(self::_getfontpath().$file)) {
$fontfile = self::_getfontpath().$file; $fontfile = self::_getfontpath().$file;
} elseif (@file_exists($file)) { } elseif (@TCPDF_STATIC::file_exists($file)) {
$fontfile = $file; $fontfile = $file;
} }
return $fontfile; return $fontfile;
@ -2003,7 +2003,11 @@ class TCPDF_FONTS {
$chars = str_split($str); $chars = str_split($str);
$carr = array_map('ord', $chars); $carr = array_map('ord', $chars);
} }
if (is_array($currentfont['subsetchars']) && is_array($carr)) {
$currentfont['subsetchars'] += array_fill_keys($carr, true); $currentfont['subsetchars'] += array_fill_keys($carr, true);
} else {
$currentfont['subsetchars'] = array_merge($currentfont['subsetchars'], $carr);
}
return $carr; return $carr;
} }

View file

@ -161,12 +161,8 @@ class TCPDF_IMAGES {
*/ */
public static function _parsejpeg($file) { public static function _parsejpeg($file) {
// check if is a local file // check if is a local file
if (!@file_exists($file)) { if (!@TCPDF_STATIC::file_exists($file)) {
// try to encode spaces on filename return false;
$tfile = str_replace(' ', '%20', $file);
if (@file_exists($tfile)) {
$file = $tfile;
}
} }
$a = getimagesize($file); $a = getimagesize($file);
if (empty($a)) { if (empty($a)) {

View file

@ -55,7 +55,7 @@ class TCPDF_STATIC {
* Current TCPDF version. * Current TCPDF version.
* @private static * @private static
*/ */
private static $tcpdf_version = '6.2.13'; private static $tcpdf_version = '6.2.26';
/** /**
* String alias for total number of pages. * String alias for total number of pages.
@ -1774,39 +1774,6 @@ class TCPDF_STATIC {
return $angle; return $angle;
} }
// ====================================================================================================================
// REIMPLEMENTED
// ====================================================================================================================
/** /**
* Split string by a regular expression. * 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 * This is a wrapper for the preg_split function to avoid the bug: https://bugs.php.net/bug.php?id=45850
@ -1854,6 +1821,49 @@ class TCPDF_STATIC {
return fopen($filename, $mode); return fopen($filename, $mode);
} }
/**
* Check if the URL exist.
* @param url (string) URL to check.
* @return Returns TRUE if the URL exists; FALSE otherwise.
* @public static
*/
public static function url_exists($url) {
$crs = curl_init();
curl_setopt($crs, CURLOPT_URL, $url);
curl_setopt($crs, CURLOPT_NOBODY, true);
curl_setopt($crs, CURLOPT_FAILONERROR, true);
if ((ini_get('open_basedir') == '') && (!ini_get('safe_mode'))) {
curl_setopt($crs, CURLOPT_FOLLOWLOCATION, true);
}
curl_setopt($crs, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($crs, CURLOPT_TIMEOUT, 30);
curl_setopt($crs, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($crs, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($crs, CURLOPT_USERAGENT, 'tc-lib-file');
curl_exec($crs);
$code = curl_getinfo($crs, CURLINFO_HTTP_CODE);
curl_close($crs);
return ($code == 200);
}
/**
* Wrapper for file_exists.
* Checks whether a file or directory exists.
* Only allows some protocols and local files.
* @param filename (string) Path to the file or directory.
* @return Returns TRUE if the file or directory specified by filename exists; FALSE otherwise.
* @public static
*/
public static function file_exists($filename) {
if (preg_match('|^https?://|', $filename) == 1) {
return self::url_exists($filename);
}
if (strpos($filename, '://')) {
return false; // only support http and https wrappers for security reasons
}
return @file_exists($filename);
}
/** /**
* Reads entire file into a string. * Reads entire file into a string.
* The file can be also an URL. * The file can be also an URL.
@ -1910,12 +1920,14 @@ class TCPDF_STATIC {
&& !preg_match('%^//%', $file) && !preg_match('%^//%', $file)
) { ) {
$urldata = @parse_url($_SERVER['SCRIPT_URI']); $urldata = @parse_url($_SERVER['SCRIPT_URI']);
return $urldata['scheme'].'://'.$urldata['host'].(($file[0] == '/') ? '' : '/').$file; $alt[] = $urldata['scheme'].'://'.$urldata['host'].(($file[0] == '/') ? '' : '/').$file;
} }
// //
$alt = array_unique($alt); $alt = array_unique($alt);
//var_dump($alt);exit;//DEBUG
foreach ($alt as $path) { foreach ($alt as $path) {
if (!self::file_exists($path)) {
return false;
}
$ret = @file_get_contents($path); $ret = @file_get_contents($path);
if ($ret !== false) { if ($ret !== false) {
return $ret; return $ret;
@ -1949,8 +1961,6 @@ class TCPDF_STATIC {
return false; return false;
} }
/** /**
* Get ULONG from string (Big Endian 32-bit unsigned integer). * Get ULONG from string (Big Endian 32-bit unsigned integer).
* @param $str (string) string from where to extract value * @param $str (string) string from where to extract value

View file

@ -1,12 +1,23 @@
Description of TCPDF library import 6.2.13 Description of TCPDF library import 6.2.26
=========================================== ==========================================
* download library from https://github.com/tecnickcom/TCPDF/releases * download library from https://github.com/tecnickcom/TCPDF/releases
* delete examples/, tools/ and tcpdf_import.php * delete examples/, tools/ and tcpdf_import.php
* remove tcpdf_import.php from composer.json * remove tcpdf_import.php from composer.json
* remove all fonts that were not already present * remove all fonts that were not already present
* visit http://127.0.0.1/lib/tests/other/pdflibtestpage.php and view the pdf * visit http://127.0.0.1/lib/tests/other/pdflibtestpage.php and view the pdf
* check the status of https://github.com/tecnickcom/TCPDF/pull/74 and re-apply if not merged/closed (6.2.16 and up should contain it).
* verify that https://github.com/tecnickcom/TCPDF/pull/91 is included in the imported library (6.2.25 and up should contain it). Important
---------
A new version of the libray is being developed @ https://github.com/tecnickcom/tc-lib-pdf . Check periodically when it's ready
and if it's a drop-in replacement for the legacy tcpdf one.
2019/05/06
----------
Upgrade to tcpdf TCPDF 6.2.26 (MDL-64794)
by Eloy Lafuente <stronk7@moodle.org>
- https://github.com/tecnickcom/TCPDF/pull/74 has been already merged upstream (6.2.16 and up), so we don't need to apply it.
- https://github.com/tecnickcom/TCPDF/pull/91 has been already merged upstream (6.2.19 and up), so we don't need to apply it.
2017/10/02 2017/10/02
---------- ----------

View file

@ -1,13 +1,13 @@
<?php <?php
//============================================================+ //============================================================+
// File name : tcpdf.php // File name : tcpdf.php
// Version : 6.2.13 // Version : 6.2.26
// Begin : 2002-08-03 // Begin : 2002-08-03
// Last Update : 2015-06-18 // Last Update : 2018-09-14
// Author : Nicola Asuni - Tecnick.com LTD - www.tecnick.com - info@tecnick.com // Author : Nicola Asuni - Tecnick.com LTD - www.tecnick.com - info@tecnick.com
// License : GNU-LGPL v3 (http://www.gnu.org/copyleft/lesser.html) // License : GNU-LGPL v3 (http://www.gnu.org/copyleft/lesser.html)
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Copyright (C) 2002-2015 Nicola Asuni - Tecnick.com LTD // Copyright (C) 2002-2018 Nicola Asuni - Tecnick.com LTD
// //
// This file is part of TCPDF software library. // This file is part of TCPDF software library.
// //
@ -104,7 +104,7 @@
* Tools to encode your unicode fonts are on fonts/utils directory.</p> * Tools to encode your unicode fonts are on fonts/utils directory.</p>
* @package com.tecnick.tcpdf * @package com.tecnick.tcpdf
* @author Nicola Asuni * @author Nicola Asuni
* @version 6.2.8 * @version 6.2.26
*/ */
// TCPDF configuration // TCPDF configuration
@ -128,8 +128,11 @@ 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> * 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 * @package com.tecnick.tcpdf
* @brief PHP class for generating PDF documents without requiring external extensions. * @brief PHP class for generating PDF documents without requiring external extensions.
* @version 6.2.8 * @version 6.2.26
* @author Nicola Asuni - info@tecnick.com * @author Nicola Asuni - info@tecnick.com
* @IgnoreAnnotation("protected")
* @IgnoreAnnotation("public")
* @IgnoreAnnotation("pre")
*/ */
class TCPDF { class TCPDF {
@ -1994,10 +1997,6 @@ class TCPDF {
* @since 1.53.0.TC016 * @since 1.53.0.TC016
*/ */
public function __destruct() { public function __destruct() {
// restore internal encoding
if (isset($this->internal_encoding) AND !empty($this->internal_encoding)) {
mb_internal_encoding($this->internal_encoding);
}
// cleanup // cleanup
$this->_destroy(true); $this->_destroy(true);
} }
@ -4257,7 +4256,7 @@ class TCPDF {
// true when the font style variation is missing // true when the font style variation is missing
$missing_style = false; $missing_style = false;
// search and include font file // search and include font file
if (TCPDF_STATIC::empty_string($fontfile) OR (!@file_exists($fontfile))) { if (TCPDF_STATIC::empty_string($fontfile) OR (!@TCPDF_STATIC::file_exists($fontfile))) {
// build a standard filenames for specified font // build a standard filenames for specified font
$tmp_fontfile = str_replace(' ', '', $family).strtolower($style).'.php'; $tmp_fontfile = str_replace(' ', '', $family).strtolower($style).'.php';
$fontfile = TCPDF_FONTS::getFontFullPath($tmp_fontfile, $fontdir); $fontfile = TCPDF_FONTS::getFontFullPath($tmp_fontfile, $fontdir);
@ -4269,7 +4268,7 @@ class TCPDF {
} }
} }
// include font file // include font file
if (!TCPDF_STATIC::empty_string($fontfile) AND (@file_exists($fontfile))) { if (!TCPDF_STATIC::empty_string($fontfile) AND (@TCPDF_STATIC::file_exists($fontfile))) {
include($fontfile); include($fontfile);
} else { } else {
$this->Error('Could not include font definition file: '.$family.''); $this->Error('Could not include font definition file: '.$family.'');
@ -4453,6 +4452,7 @@ class TCPDF {
* @see SetFont() * @see SetFont()
*/ */
public function SetFontSize($size, $out=true) { public function SetFontSize($size, $out=true) {
$size = (float)$size;
// font size in points // font size in points
$this->FontSizePt = $size; $this->FontSizePt = $size;
// font size in user units // font size in user units
@ -4809,19 +4809,19 @@ class TCPDF {
$this->PageAnnots[$page][] = array('n' => ++$this->n, 'x' => $x, 'y' => $y, 'w' => $w, 'h' => $h, 'txt' => $text, 'opt' => $opt, 'numspaces' => $spaces); $this->PageAnnots[$page][] = array('n' => ++$this->n, 'x' => $x, 'y' => $y, 'w' => $w, 'h' => $h, 'txt' => $text, 'opt' => $opt, 'numspaces' => $spaces);
if (!$this->pdfa_mode) { if (!$this->pdfa_mode) {
if ((($opt['Subtype'] == 'FileAttachment') OR ($opt['Subtype'] == 'Sound')) AND (!TCPDF_STATIC::empty_string($opt['FS'])) if ((($opt['Subtype'] == 'FileAttachment') OR ($opt['Subtype'] == 'Sound')) AND (!TCPDF_STATIC::empty_string($opt['FS']))
AND (@file_exists($opt['FS']) OR TCPDF_STATIC::isValidURL($opt['FS'])) AND (@TCPDF_STATIC::file_exists($opt['FS']) OR TCPDF_STATIC::isValidURL($opt['FS']))
AND (!isset($this->embeddedfiles[basename($opt['FS'])]))) { AND (!isset($this->embeddedfiles[basename($opt['FS'])]))) {
$this->embeddedfiles[basename($opt['FS'])] = array('f' => ++$this->n, 'n' => ++$this->n, 'file' => $opt['FS']); $this->embeddedfiles[basename($opt['FS'])] = array('f' => ++$this->n, 'n' => ++$this->n, 'file' => $opt['FS']);
} }
} }
// Add widgets annotation's icons // Add widgets annotation's icons
if (isset($opt['mk']['i']) AND @file_exists($opt['mk']['i'])) { if (isset($opt['mk']['i']) AND @TCPDF_STATIC::file_exists($opt['mk']['i'])) {
$this->Image($opt['mk']['i'], '', '', 10, 10, '', '', '', false, 300, '', false, false, 0, false, true); $this->Image($opt['mk']['i'], '', '', 10, 10, '', '', '', false, 300, '', false, false, 0, false, true);
} }
if (isset($opt['mk']['ri']) AND @file_exists($opt['mk']['ri'])) { if (isset($opt['mk']['ri']) AND @TCPDF_STATIC::file_exists($opt['mk']['ri'])) {
$this->Image($opt['mk']['ri'], '', '', 0, 0, '', '', '', false, 300, '', false, false, 0, false, true); $this->Image($opt['mk']['ri'], '', '', 0, 0, '', '', '', false, 300, '', false, false, 0, false, true);
} }
if (isset($opt['mk']['ix']) AND @file_exists($opt['mk']['ix'])) { if (isset($opt['mk']['ix']) AND @TCPDF_STATIC::file_exists($opt['mk']['ix'])) {
$this->Image($opt['mk']['ix'], '', '', 0, 0, '', '', '', false, 300, '', false, false, 0, false, true); $this->Image($opt['mk']['ix'], '', '', 0, 0, '', '', '', false, 300, '', false, false, 0, false, true);
} }
} }
@ -5769,10 +5769,9 @@ class TCPDF {
$this->resetLastH(); $this->resetLastH();
} }
if (!TCPDF_STATIC::empty_string($y)) { if (!TCPDF_STATIC::empty_string($y)) {
$this->SetY($y); $this->SetY($y); // set y in order to convert negative y values to positive ones
} else {
$y = $this->GetY();
} }
$y = $this->GetY();
$resth = 0; $resth = 0;
if (($h > 0) AND $this->inPageBody() AND (($y + $h + $mc_margin['T'] + $mc_margin['B']) > $this->PageBreakTrigger)) { if (($h > 0) AND $this->inPageBody() AND (($y + $h + $mc_margin['T'] + $mc_margin['B']) > $this->PageBreakTrigger)) {
// spit cell in more pages/columns // spit cell in more pages/columns
@ -6845,13 +6844,9 @@ class TCPDF {
$file = substr($file, 1); $file = substr($file, 1);
$exurl = $file; $exurl = $file;
} }
// check if is a local file // check if file exist and it is valid
if (!@file_exists($file)) { if (!@TCPDF_STATIC::file_exists($file)) {
// try to encode spaces on filename return false;
$tfile = str_replace(' ', '%20', $file);
if (@file_exists($tfile)) {
$file = $tfile;
}
} }
if (($imsize = @getimagesize($file)) === FALSE) { if (($imsize = @getimagesize($file)) === FALSE) {
if (in_array($file, $this->imagekeys)) { if (in_array($file, $this->imagekeys)) {
@ -7750,6 +7745,10 @@ class TCPDF {
* @since 4.5.016 (2009-02-24) * @since 4.5.016 (2009-02-24)
*/ */
public function _destroy($destroyall=false, $preserve_objcopy=false) { public function _destroy($destroyall=false, $preserve_objcopy=false) {
// restore internal encoding
if (isset($this->internal_encoding) AND !empty($this->internal_encoding)) {
mb_internal_encoding($this->internal_encoding);
}
if ($destroyall AND !$preserve_objcopy) { if ($destroyall AND !$preserve_objcopy) {
// remove all temporary files // remove all temporary files
$tmpfiles = glob(K_PATH_CACHE.'__tcpdf_'.$this->file_id.'_*'); $tmpfiles = glob(K_PATH_CACHE.'__tcpdf_'.$this->file_id.'_*');
@ -8157,7 +8156,9 @@ class TCPDF {
$annots .= ' /FT /'.$pl['opt']['ft']; $annots .= ' /FT /'.$pl['opt']['ft'];
$formfield = true; $formfield = true;
} }
if ($pl['opt']['subtype'] !== 'Link') {
$annots .= ' /Contents '.$this->_textstring($pl['txt'], $annot_obj_id); $annots .= ' /Contents '.$this->_textstring($pl['txt'], $annot_obj_id);
}
$annots .= ' /P '.$this->page_obj_id[$n].' 0 R'; $annots .= ' /P '.$this->page_obj_id[$n].' 0 R';
$annots .= ' /NM '.$this->_datastring(sprintf('%04u-%04u', $n, $key), $annot_obj_id); $annots .= ' /NM '.$this->_datastring(sprintf('%04u-%04u', $n, $key), $annot_obj_id);
$annots .= ' /M '.$this->_datestring($annot_obj_id, $this->doc_modification_timestamp); $annots .= ' /M '.$this->_datestring($annot_obj_id, $this->doc_modification_timestamp);
@ -9646,7 +9647,7 @@ class TCPDF {
protected function _putcatalog() { protected function _putcatalog() {
// put XMP // put XMP
$xmpobj = $this->_putXMP(); $xmpobj = $this->_putXMP();
// if required, add standard sRGB_IEC61966-2.1 blackscaled ICC colour profile // if required, add standard sRGB ICC colour profile
if ($this->pdfa_mode OR $this->force_srgb) { if ($this->pdfa_mode OR $this->force_srgb) {
$iccobj = $this->_newobj(); $iccobj = $this->_newobj();
$icc = file_get_contents(dirname(__FILE__).'/include/sRGB.icc'); $icc = file_get_contents(dirname(__FILE__).'/include/sRGB.icc');
@ -15190,7 +15191,7 @@ class TCPDF {
* @since 3.1.000 (2008-06-09) * @since 3.1.000 (2008-06-09)
* @public * @public
*/ */
public function write1DBarcode($code, $type, $x='', $y='', $w='', $h='', $xres='', $style='', $align='') { public function write1DBarcode($code, $type, $x='', $y='', $w='', $h='', $xres='', $style=array(), $align='') {
if (TCPDF_STATIC::empty_string(trim($code))) { if (TCPDF_STATIC::empty_string(trim($code))) {
return; return;
} }
@ -15509,7 +15510,7 @@ class TCPDF {
* @since 4.5.037 (2009-04-07) * @since 4.5.037 (2009-04-07)
* @public * @public
*/ */
public function write2DBarcode($code, $type, $x='', $y='', $w='', $h='', $style='', $align='', $distort=false) { public function write2DBarcode($code, $type, $x='', $y='', $w='', $h='', $style=array(), $align='', $distort=false) {
if (TCPDF_STATIC::empty_string(trim($code))) { if (TCPDF_STATIC::empty_string(trim($code))) {
return; return;
} }
@ -17176,10 +17177,10 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value:
if ($cell) { if ($cell) {
if ($this->rtl) { if ($this->rtl) {
$this->x -= $this->cell_padding['R']; $this->x -= $this->cell_padding['R'];
$this->lMargin += $this->cell_padding['R']; $this->lMargin += $this->cell_padding['L'];
} else { } else {
$this->x += $this->cell_padding['L']; $this->x += $this->cell_padding['L'];
$this->rMargin += $this->cell_padding['L']; $this->rMargin += $this->cell_padding['R'];
} }
} }
if ($this->customlistindent >= 0) { if ($this->customlistindent >= 0) {
@ -18316,7 +18317,8 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value:
} }
// text // text
$this->htmlvspace = 0; $this->htmlvspace = 0;
if ((!$this->premode) AND $this->isRTLTextDir()) { $isRTLString = preg_match(TCPDF_FONT_DATA::$uni_RE_PATTERN_RTL, $dom[$key]['value']) || preg_match(TCPDF_FONT_DATA::$uni_RE_PATTERN_ARABIC, $dom[$key]['value']);
if ((!$this->premode) AND $this->isRTLTextDir() AND !$isRTLString) {
// reverse spaces order // reverse spaces order
$lsp = ''; // left spaces $lsp = ''; // left spaces
$rsp = ''; // right spaces $rsp = ''; // right spaces
@ -18331,7 +18333,7 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value:
if ($newline) { if ($newline) {
if (!$this->premode) { if (!$this->premode) {
$prelen = strlen($dom[$key]['value']); $prelen = strlen($dom[$key]['value']);
if ($this->isRTLTextDir()) { if ($this->isRTLTextDir() AND !$isRTLString) {
// right trim except non-breaking space // right trim except non-breaking space
$dom[$key]['value'] = $this->stringRightTrim($dom[$key]['value']); $dom[$key]['value'] = $this->stringRightTrim($dom[$key]['value']);
} else { } else {
@ -18815,14 +18817,37 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value:
break; break;
} }
case 'img': { case 'img': {
if (!empty($tag['attribute']['src'])) { if (empty($tag['attribute']['src'])) {
if ($tag['attribute']['src'][0] === '@') { break;
}
$imgsrc = $tag['attribute']['src'];
if ($imgsrc[0] === '@') {
// data stream // data stream
$tag['attribute']['src'] = '@'.base64_decode(substr($tag['attribute']['src'], 1)); $imgsrc = '@'.base64_decode(substr($imgsrc, 1));
$type = ''; $type = '';
} else { } else {
if (($imgsrc[0] === '/') AND !empty($_SERVER['DOCUMENT_ROOT']) AND ($_SERVER['DOCUMENT_ROOT'] != '/')) {
// fix image path
$findroot = strpos($imgsrc, $_SERVER['DOCUMENT_ROOT']);
if (($findroot === false) OR ($findroot > 1)) {
if (substr($_SERVER['DOCUMENT_ROOT'], -1) == '/') {
$imgsrc = substr($_SERVER['DOCUMENT_ROOT'], 0, -1).$imgsrc;
} else {
$imgsrc = $_SERVER['DOCUMENT_ROOT'].$imgsrc;
}
}
$imgsrc = urldecode($imgsrc);
$testscrtype = @parse_url($imgsrc);
if (empty($testscrtype['query'])) {
// convert URL to server path
$imgsrc = str_replace(K_PATH_URL, K_PATH_MAIN, $imgsrc);
} elseif (preg_match('|^https?://|', $imgsrc) !== 1) {
// convert URL to server path
$imgsrc = str_replace(K_PATH_MAIN, K_PATH_URL, $imgsrc);
}
}
// get image type // get image type
$type = TCPDF_IMAGES::getImageFileType($tag['attribute']['src']); $type = TCPDF_IMAGES::getImageFileType($imgsrc);
} }
if (!isset($tag['width'])) { if (!isset($tag['width'])) {
$tag['width'] = 0; $tag['width'] = 0;
@ -18890,11 +18915,11 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value:
$ih = $this->getHTMLUnitToUnits($tag['height'], ($tag['fontsize'] / $this->k), 'px', false); $ih = $this->getHTMLUnitToUnits($tag['height'], ($tag['fontsize'] / $this->k), 'px', false);
} }
if (($type == 'eps') OR ($type == 'ai')) { if (($type == 'eps') OR ($type == 'ai')) {
$this->ImageEps($tag['attribute']['src'], $xpos, $this->y, $iw, $ih, $imglink, true, $align, '', $border, true); $this->ImageEps($imgsrc, $xpos, $this->y, $iw, $ih, $imglink, true, $align, '', $border, true);
} elseif ($type == 'svg') { } elseif ($type == 'svg') {
$this->ImageSVG($tag['attribute']['src'], $xpos, $this->y, $iw, $ih, $imglink, $align, '', $border, true); $this->ImageSVG($imgsrc, $xpos, $this->y, $iw, $ih, $imglink, $align, '', $border, true);
} else { } else {
$this->Image($tag['attribute']['src'], $xpos, $this->y, $iw, $ih, '', $imglink, $align, false, 300, '', false, false, $border, false, false, true); $this->Image($imgsrc, $xpos, $this->y, $iw, $ih, '', $imglink, $align, false, 300, '', false, false, $border, false, false, true);
} }
switch($align) { switch($align) {
case 'T': { case 'T': {
@ -18910,7 +18935,6 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value:
break; break;
} }
} }
}
break; break;
} }
case 'dl': { case 'dl': {
@ -21511,7 +21535,7 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value:
} else { } else {
// placemark to be replaced with the correct number // placemark to be replaced with the correct number
$pagenum = '{#'.($outline['p']).'}'; $pagenum = '{#'.($outline['p']).'}';
if ($templates['F'.$outline['l']]) { if (isset($templates['F'.$outline['l']]) && $templates['F'.$outline['l']]) {
$pagenum = '{'.$pagenum.'}'; $pagenum = '{'.$pagenum.'}';
} }
$maxpage = max($maxpage, $outline['p']); $maxpage = max($maxpage, $outline['p']);
@ -24204,9 +24228,12 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value:
} }
$img = urldecode($img); $img = urldecode($img);
$testscrtype = @parse_url($img); $testscrtype = @parse_url($img);
if (!isset($testscrtype['query']) OR empty($testscrtype['query'])) { if (empty($testscrtype['query'])) {
// convert URL to server path // convert URL to server path
$img = str_replace(K_PATH_URL, K_PATH_MAIN, $img); $img = str_replace(K_PATH_URL, K_PATH_MAIN, $img);
} elseif (preg_match('|^https?://|', $img) !== 1) {
// convert server path to URL
$img = str_replace(K_PATH_MAIN, K_PATH_URL, $img);
} }
} }
// get image type // get image type

View file

@ -130,7 +130,7 @@
<location>tcpdf</location> <location>tcpdf</location>
<name>TCPDF</name> <name>TCPDF</name>
<license>LGPL</license> <license>LGPL</license>
<version>6.2.13</version> <version>6.2.26</version>
<licenseversion>3</licenseversion> <licenseversion>3</licenseversion>
</library> </library>
<library> <library>