Skip to content

Commit 1029d4f

Browse files
authored
Merge branch 'main' into patch-1
2 parents 0d12658 + 79bfbb4 commit 1029d4f

22 files changed

+447
-310
lines changed

.github/workflows/lint-docs.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
name: lint php documentation
22

3+
permissions:
4+
contents: read
5+
36
on:
47
push:
58
branches:
@@ -12,7 +15,7 @@ jobs:
1215
lint-docs:
1316
runs-on: ubuntu-latest
1417
steps:
15-
- uses: actions/checkout@v3
18+
- uses: actions/checkout@v4
1619
- name: lint php documentation
1720
uses: sudo-bot/action-doctum@dev
1821
with:

.github/workflows/tests.yml

Lines changed: 23 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
name: Run tests
22

3+
env:
4+
XDEBUG_MODE: coverage
5+
6+
permissions:
7+
contents: read
8+
39
on:
410
push:
511
branches:
@@ -16,45 +22,21 @@ jobs:
1622
strategy:
1723
fail-fast: false
1824
matrix:
19-
php-version: ["5.3", "5.4", "5.5", "5.6", "7.0", "7.1", "7.2", "7.3", "7.4", "8.0", "8.1", "8.2"]
20-
os: [macos-latest, windows-latest]
25+
php-version: ["7.1", "7.2", "7.3", "7.4", "8.0", "8.1", "8.2"]
26+
os: [ubuntu-latest]
2127
experimental: [false]
22-
php-extensions: ["bcmath, imagick, gd"]
28+
php-extensions: ["bcmath, curl, imagick, gd"]
2329
coverage-extension: ["none"]
24-
exclude:
25-
# For now, we do not know how to run workflow on Windows
26-
# with imagick PHP extension for PHP 5.3 - 5.6
27-
- { php-version: '5.3', os: windows-latest }
28-
- { php-version: '5.4', os: windows-latest }
29-
- { php-version: '5.5', os: windows-latest }
30-
- { php-version: '5.6', os: windows-latest }
31-
# Somehow some tests fail under Windows and PHP 7.0,
32-
# so we disable that run for now
33-
- { php-version: '7.0', os: windows-latest }
30+
# Add more specific tests
3431
include:
35-
- { php-version: '5.3', os: windows-latest, experimental: false, php-extensions: 'bcmath, gd', coverage-extension: 'none' }
36-
- { php-version: '5.4', os: windows-latest, experimental: false, php-extensions: 'bcmath, gd', coverage-extension: 'none' }
37-
- { php-version: '5.5', os: windows-latest, experimental: false, php-extensions: 'bcmath, gd', coverage-extension: 'none' }
38-
- { php-version: '5.6', os: windows-latest, experimental: false, php-extensions: 'bcmath, gd', coverage-extension: 'none' }
39-
# Specify coverage extension for Ubuntu runs
40-
- { php-version: '5.3', os: ubuntu-latest, experimental: false, php-extensions: 'bcmath, imagick, gd', coverage-extension: 'xdebug' }
41-
- { php-version: '5.4', os: ubuntu-latest, experimental: false, php-extensions: 'bcmath, imagick, gd', coverage-extension: 'xdebug' }
42-
- { php-version: '5.5', os: ubuntu-latest, experimental: false, php-extensions: 'bcmath, imagick, gd', coverage-extension: 'xdebug' }
43-
- { php-version: '5.6', os: ubuntu-latest, experimental: false, php-extensions: 'bcmath, imagick, gd', coverage-extension: 'xdebug' }
44-
- { php-version: '7.0', os: ubuntu-latest, experimental: false, php-extensions: 'bcmath, imagick, gd', coverage-extension: 'xdebug' }
45-
# pcov is available from PHP 7.1
46-
- { php-version: '7.1', os: ubuntu-latest, experimental: false, php-extensions: 'bcmath, imagick, gd', coverage-extension: 'pcov' }
47-
- { php-version: '7.2', os: ubuntu-latest, experimental: false, php-extensions: 'bcmath, imagick, gd', coverage-extension: 'pcov' }
48-
- { php-version: '7.3', os: ubuntu-latest, experimental: false, php-extensions: 'bcmath, imagick, gd', coverage-extension: 'pcov' }
49-
- { php-version: '7.4', os: ubuntu-latest, experimental: false, php-extensions: 'bcmath, imagick, gd', coverage-extension: 'pcov' }
50-
- { php-version: '8.0', os: ubuntu-latest, experimental: false, php-extensions: 'bcmath, imagick, gd', coverage-extension: 'pcov' }
51-
- { php-version: '8.1', os: ubuntu-latest, experimental: false, php-extensions: 'bcmath, imagick, gd', coverage-extension: 'pcov' }
52-
- { php-version: '8.2', os: ubuntu-latest, experimental: false, php-extensions: 'bcmath, imagick, gd', coverage-extension: 'pcov' }
53-
- { php-version: 'nightly', os: ubuntu-latest, experimental: true, php-extensions: 'bcmath, imagick, gd', coverage-extension: 'pcov' }
32+
#- { php-version: '8.2', experimental: false, os: macos-latest, php-extensions: 'bcmath, curl, imagick, gd', coverage-extension: 'none' }
33+
- { php-version: '8.2', experimental: false, os: windows-latest, php-extensions: 'bcmath, curl, imagick, gd', coverage-extension: 'none' }
34+
- { php-version: '8.3', experimental: true, os: ubuntu-latest, php-extensions: 'bcmath, curl, imagick, gd', coverage-extension: 'pcov' }
35+
- { php-version: 'nightly', experimental: true, os: ubuntu-latest, php-extensions: 'bcmath, curl, imagick, gd', coverage-extension: 'pcov' }
5436
env:
5537
PDFINFO_BINARY: ${{ (matrix.os == 'ubuntu-latest') && '/usr/bin/pdfinfo' || ((matrix.os == 'macos-latest') && '/usr/local/bin/pdfinfo' || 'C:\ProgramData\Chocolatey\bin\pdfinfo.exe') }}
5638
steps:
57-
- uses: actions/checkout@v3
39+
- uses: actions/checkout@v4
5840
- name: Install pdfinfo, pdftopng or pdftoppm
5941
uses: ConorMacBride/install-package@v1
6042
with:
@@ -81,14 +63,14 @@ jobs:
8163
- name: List php modules using "no php ini" mode
8264
run: php -m -n
8365
- name: Cache module
84-
uses: actions/cache@v3
66+
uses: actions/cache@v4
8567
with:
8668
path: ~/.composer/cache/
8769
key: composer-cache
8870
- name: Install dependencies
89-
run: composer install --no-interaction
71+
run: composer update --no-interaction
9072
- name: Install test dependencies
91-
run: cd ./tests && composer install --no-interaction && cd ../
73+
run: cd ./tests && composer update --no-interaction && cd ../
9274
- name: Run shell-based test suite
9375
if: runner.os == 'Linux'
9476
run: ./tests/launch.sh
@@ -118,18 +100,17 @@ jobs:
118100
name: Static Analysis
119101
runs-on: ubuntu-latest
120102
steps:
121-
- uses: actions/checkout@v3
122-
- name: Use php 8.0
103+
- uses: actions/checkout@v4
104+
- name: Use php 8.2
123105
uses: shivammathur/setup-php@v2
124106
with:
125-
php-version: 8.0
126-
tools: composer:v2
107+
php-version: 8.2
127108
- name: Cache module
128-
uses: actions/cache@v3
109+
uses: actions/cache@v4
129110
with:
130111
path: ~/.composer/cache/
131112
key: composer-cache
132113
- name: Install phpstan
133114
run: composer require --dev phpstan/phpstan
134115
- name: Analyse files
135-
run: ./vendor/bin/phpstan --memory-limit=2G
116+
run: ./vendor/bin/phpstan --memory-limit=6G

CHANGELOG.TXT

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,63 @@
1+
6.8.1 (2025-01-26)
2+
- Check relative paths on SVG images.
3+
4+
6.8.0 (2024-12-23)
5+
- Requires PHP 7.1+ and curl extension.
6+
- Escape error message.
7+
- Use strict time-constant function to compare TCPDF-tag hashes.
8+
- Add K_CURLOPTS config array to set custom cURL options (NOTE: some defaults have changed).
9+
- Add some addTTFfont fixes from tc-lib-pdf-font.
10+
11+
6.7.8 (2024-12-13)
12+
- Improve SVG detection by checking for (mandatory) namespace.
13+
- Use late state binding now that minimum PHP version is 5.5.
14+
15+
6.7.7 (2024-10-26)
16+
- Update regular expression to avoid ReDoS (CVE-2024-22641)
17+
- [PHP 8.4] Fix: Curl CURLOPT_BINARYTRANSFER deprecated #675
18+
- SVG detection fix for inline data images #646
19+
- Fix count svg #647
20+
- Since the version 6.7.4, the "0" is considered like empty string and not displayed
21+
- Fixed handling of transparency in PDF/A mode in addExtGState method
22+
- Encrypt /DA string when document is encrypted
23+
- Improve quality of generated seed, avoid potential security pitfall
24+
- Try to use random_bytes() first if it's available
25+
- Do not include the server parameters in the generated seed, as they might contain sensitive data
26+
- Fix bug on _getannotsrefs when there are empty signature appearances but not other annot on a page
27+
- Fix SVG coordinate parser that caused drawing artifacts
28+
- Remove usage of xml_set_object() function
29+
30+
6.7.6 (2024-10-06)
31+
- Forbid access to parent folder in HTML images.
32+
33+
6.7.5 (2024-04-20)
34+
- Update GitHub actions
35+
- fix: CSV-2024-22640 (#712)
36+
37+
6.7.4 (2024-03-24)
38+
- Upgrade tcpdf tag encryption algorithm.
39+
- Fix regression issue #699.
40+
- Fix security issue.
41+
- [BREAKING CHANGE] The tcpdf HTML tag syntax has changed, see example_049.php.
42+
- New K_ALLOWED_TCPDF_TAGS configuration constant to set the allowed methods for the tcdpf HTML tag.
43+
- Raised minimum PHP version to PHP 5.5.0.
44+
45+
6.6.5 (2023-09-02)
46+
- Fix corrupted file.
47+
- Fix GitHub automation tests.
48+
- Fix SPDX license ID (#591)
49+
- Fix warning "array offset on value of type null" (#620)
50+
- Improve the README about the status of this library (#589)
51+
- Fix deprecation warning with PHP 8.1 (#614)
52+
- Fixes for PHP 8.2 in tcpdf_fonts.php (#632)
53+
- Fix some php 8+ edge cases (#630)
54+
- Fix composite glyph output (#581)
55+
- Fix "access array offset on value of type bool" with PDF/A (#583)
56+
- Fix non-numeric value warning (#627)
57+
- Fix issues with S25 barcode (#611)
58+
- Fix return type annotations (#613)
59+
- Fix some inconsistencies in type hints (#598)
60+
161
6.6.2 (2022-12-17)
262
- Ensure pregSplit return type is always array.
363
- Add ability to run tests on various operating systems (#566)

LICENSE.TXT

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
published by the Free Software Foundation, either version 3 of the
88
License, or (at your option) any later version.
99

10-
2002-2022 Nicola Asuni - Tecnick.com LTD
10+
2002-2025 Nicola Asuni - Tecnick.com LTD
1111

1212
**********************************************************************
1313
**********************************************************************

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,14 @@
66

77
* **category** Library
88
* **author** Nicola Asuni <info@tecnick.com>
9-
* **copyright** 2002-2022 Nicola Asuni - Tecnick.com LTD
9+
* **copyright** 2002-2025 Nicola Asuni - Tecnick.com LTD
1010
* **license** http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
1111
* **link** http://www.tcpdf.org
1212
* **source** https://github.com/tecnickcom/TCPDF
1313

1414

15-
## IMPORTANT
16-
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.
17-
This version should be considered obsolete, new projects should use the new version as soon it will become stable.
15+
## NOTE
16+
A new version of this library is under development at https://github.com/tecnickcom/tc-lib-pdf and as a consequence this library is in support only mode.
1817

1918

2019

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
6.6.2
1+
6.8.1

composer.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
"barcodes"
1313
],
1414
"homepage": "http://www.tcpdf.org/",
15-
"version": "6.6.2",
16-
"license": "LGPL-3.0-only",
15+
"version": "6.8.1",
16+
"license": "LGPL-3.0-or-later",
1717
"authors": [
1818
{
1919
"name": "Nicola Asuni",
@@ -22,7 +22,8 @@
2222
}
2323
],
2424
"require": {
25-
"php": ">=5.3.0"
25+
"php": ">=7.1.0",
26+
"ext-curl": "*"
2627
},
2728
"autoload": {
2829
"classmap": [

config/tcpdf_config.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,14 @@
212212
*/
213213
define('K_TCPDF_CALLS_IN_HTML', false);
214214

215+
/**
216+
* List of TCPDF methods that are allowed to be called using HTML syntax.
217+
* Note: each method name must end with surrounded with | (pipe) character.
218+
* The constant K_TCPDF_CALLS_IN_HTML must be set to true.
219+
* IMPORTANT: For security reason, disable this feature if you are allowing user HTML content.
220+
*/
221+
define('K_ALLOWED_TCPDF_TAGS', '');
222+
215223
/**
216224
* If true and PHP version is greater than 5, then the Error() method throw new exception instead of terminating the execution.
217225
*/

examples/config/tcpdf_config_alt.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,14 @@
212212
*/
213213
define('K_TCPDF_CALLS_IN_HTML', true);
214214

215+
/**
216+
* List of TCPDF methods that are allowed to be called using HTML syntax.
217+
* Note: each method name must end with surrounded with | (pipe) character.
218+
* The constant K_TCPDF_CALLS_IN_HTML must be set to true.
219+
* IMPORTANT: For security reason, disable this feature if you are allowing user HTML content.
220+
*/
221+
define('K_ALLOWED_TCPDF_TAGS', '|AddPage|Rect|SetDrawColor|write1DBarcode|');
222+
215223
/**
216224
* If true and PHP version is greater than 5, then the Error() method throw new exception instead of terminating the execution.
217225
*/

examples/example_049.php

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//============================================================+
33
// File name : example_049.php
44
// Begin : 2009-04-03
5-
// Last Update : 2014-12-10
5+
// Last Update : 2024-03-18
66
//
77
// Description : Example 049 for TCPDF class
88
// WriteHTML with TCPDF callback functions
@@ -78,36 +78,36 @@
7878
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
7979
8080
IMPORTANT:
81-
If you are printing user-generated content, tcpdf tag can be unsafe.
82-
You can disable this tag by setting to false the K_TCPDF_CALLS_IN_HTML
83-
constant on TCPDF configuration file.
81+
If you are printing user-generated content, the tcpdf tag should be considered unsafe.
82+
This tag is disabled by default by the K_TCPDF_CALLS_IN_HTML constant on TCPDF configuration file.
83+
Please use this feature only if you are in control of the HTML content and you are sure that it does not contain any harmful code.
8484
85-
For security reasons, the parameters for the 'params' attribute of TCPDF
86-
tag must be prepared as an array and encoded with the
87-
serializeTCPDFtagParameters() method (see the example below).
85+
For security reasons, the content of the TCPDF tag must be prepared and encoded with the serializeTCPDFtag() method (see the example below).
8886
8987
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
9088

9189

9290
$html = '<h1>Test TCPDF Methods in HTML</h1>
9391
<h2 style="color:red;">IMPORTANT:</h2>
94-
<span style="color:red;">If you are using user-generated content, the tcpdf tag can be unsafe.<br />
95-
You can disable this tag by setting to false the <b>K_TCPDF_CALLS_IN_HTML</b> constant on TCPDF configuration file.</span>
92+
<span style="color:red;">If you are using user-generated content, the tcpdf tag should be considered unsafe.<br />
93+
Please use this feature only if you are in control of the HTML content and you are sure that it does not contain any harmful code.<br />
94+
This feature is disabled by default by the <b>K_TCPDF_CALLS_IN_HTML</b> constant on TCPDF configuration file.</span>
9695
<h2>write1DBarcode method in HTML</h2>';
9796

98-
$params = $pdf->serializeTCPDFtagParameters(array('CODE 39', 'C39', '', '', 80, 30, 0.4, array('position'=>'S', 'border'=>true, 'padding'=>4, 'fgcolor'=>array(0,0,0), 'bgcolor'=>array(255,255,255), 'text'=>true, 'font'=>'helvetica', 'fontsize'=>8, 'stretchtext'=>4), 'N'));
99-
$html .= '<tcpdf method="write1DBarcode" params="'.$params.'" />';
97+
$data = $pdf->serializeTCPDFtag('write1DBarcode', array('CODE 39', 'C39', '', '', 80, 30, 0.4, array('position'=>'S', 'border'=>true, 'padding'=>4, 'fgcolor'=>array(0,0,0), 'bgcolor'=>array(255,255,255), 'text'=>true, 'font'=>'helvetica', 'fontsize'=>8, 'stretchtext'=>4), 'N'));
98+
$html .= '<tcpdf data="'.$data.'" />';
10099

101-
$params = $pdf->serializeTCPDFtagParameters(array('CODE 128', 'C128', '', '', 80, 30, 0.4, array('position'=>'S', 'border'=>true, 'padding'=>4, 'fgcolor'=>array(0,0,0), 'bgcolor'=>array(255,255,255), 'text'=>true, 'font'=>'helvetica', 'fontsize'=>8, 'stretchtext'=>4), 'N'));
102-
$html .= '<tcpdf method="write1DBarcode" params="'.$params.'" />';
100+
$data = $pdf->serializeTCPDFtag('write1DBarcode', array('CODE 128', 'C128', '', '', 80, 30, 0.4, array('position'=>'S', 'border'=>true, 'padding'=>4, 'fgcolor'=>array(0,0,0), 'bgcolor'=>array(255,255,255), 'text'=>true, 'font'=>'helvetica', 'fontsize'=>8, 'stretchtext'=>4), 'N'));
101+
$html .= '<tcpdf data="'.$data.'" />';
103102

104-
$html .= '<tcpdf method="AddPage" /><h2>Graphic Functions</h2>';
103+
$data = $pdf->serializeTCPDFtag('AddPage');
104+
$html .= '<tcpdf data="'.$data.'" /><h2>Graphic Functions</h2>';
105105

106-
$params = $pdf->serializeTCPDFtagParameters(array(0));
107-
$html .= '<tcpdf method="SetDrawColor" params="'.$params.'" />';
106+
$data = $pdf->serializeTCPDFtag('SetDrawColor', array(0));
107+
$html .= '<tcpdf data="'.$data.'" />';
108108

109-
$params = $pdf->serializeTCPDFtagParameters(array(50, 50, 40, 10, 'DF', array(), array(0,128,255)));
110-
$html .= '<tcpdf method="Rect" params="'.$params.'" />';
109+
$data = $pdf->serializeTCPDFtag('Rect', array(50, 50, 40, 10, 'DF', array(), array(0,128,255)));
110+
$html .= '<tcpdf data="'.$data.'" />';
111111

112112

113113
// output the HTML content

0 commit comments

Comments
 (0)