This commit is contained in:
wangjinlei
2022-06-24 10:34:21 +08:00
parent 8930873c92
commit f218969af8
605 changed files with 1891 additions and 146381 deletions

View File

@@ -7,7 +7,7 @@
// Author : Nicola Asuni - Tecnick.com LTD - www.tecnick.com - info@tecnick.com
// License : GNU-LGPL v3 (http://www.gnu.org/copyleft/lesser.html)
// -------------------------------------------------------------------
// Copyright (C) 2002-2015 Nicola Asuni - Tecnick.com LTD
// Copyright (C) 2002-2021 Nicola Asuni - Tecnick.com LTD
//
// This file is part of TCPDF software library.
//
@@ -55,7 +55,7 @@ class TCPDF_STATIC {
* Current TCPDF version.
* @private static
*/
private static $tcpdf_version = '6.4.2';
private static $tcpdf_version = '6.4.4';
/**
* String alias for total number of pages.
@@ -449,8 +449,12 @@ class TCPDF_STATIC {
$padding = 16 - (strlen($text) % 16);
$text .= str_repeat(chr($padding), $padding);
if (extension_loaded('openssl')) {
$iv = openssl_random_pseudo_bytes (openssl_cipher_iv_length('aes-256-cbc'));
$text = openssl_encrypt($text, 'aes-256-cbc', $key, OPENSSL_RAW_DATA, $iv);
$algo = 'aes-256-cbc';
if (strlen($key) == 16) {
$algo = 'aes-128-cbc';
}
$iv = openssl_random_pseudo_bytes(openssl_cipher_iv_length($algo));
$text = openssl_encrypt($text, $algo, $key, OPENSSL_RAW_DATA, $iv);
return $iv.substr($text, 0, -16);
}
$iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC), MCRYPT_RAND);
@@ -471,8 +475,12 @@ class TCPDF_STATIC {
*/
public static function _AESnopad($key, $text) {
if (extension_loaded('openssl')) {
$iv = str_repeat("\x00", openssl_cipher_iv_length('aes-256-cbc'));
$text = openssl_encrypt($text, 'aes-256-cbc', $key, OPENSSL_RAW_DATA, $iv);
$algo = 'aes-256-cbc';
if (strlen($key) == 16) {
$algo = 'aes-128-cbc';
}
$iv = str_repeat("\x00", openssl_cipher_iv_length($algo));
$text = openssl_encrypt($text, $algo, $key, OPENSSL_RAW_DATA, $iv);
return substr($text, 0, -16);
}
$iv = str_repeat("\x00", mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC));
@@ -498,7 +506,7 @@ class TCPDF_STATIC {
return $out;
}
if ($last_enc_key != $key) {
$k = str_repeat($key, ((256 / strlen($key)) + 1));
$k = str_repeat($key, (int) ((256 / strlen($key)) + 1));
$rc4 = range(0, 255);
$j = 0;
for ($i = 0; $i < 256; ++$i) {
@@ -1132,8 +1140,8 @@ class TCPDF_STATIC {
* Cleanup HTML code (requires HTML Tidy library).
* @param string $html htmlcode to fix
* @param string $default_css CSS commands to add
* @param array $tagvs parameters for setHtmlVSpace method
* @param array $tidy_options options for tidy_parse_string function
* @param array|null $tagvs parameters for setHtmlVSpace method
* @param array|null $tidy_options options for tidy_parse_string function
* @param array $tagvspaces Array of vertical spaces for tags.
* @return string XHTML code cleaned up
* @author Nicola Asuni
@@ -1143,7 +1151,7 @@ class TCPDF_STATIC {
*/
public static function fixHTMLCode($html, $default_css, $tagvs, $tidy_options, &$tagvspaces) {
// configure parameters for HTML Tidy
if ($tidy_options === '') {
if (TCPDF_STATIC::empty_string($tidy_options)) {
$tidy_options = array (
'clean' => 1,
'drop-empty-paras' => 0,
@@ -1190,7 +1198,7 @@ class TCPDF_STATIC {
// remove some empty tag blocks
$html = preg_replace('/<div([^\>]*)><\/div>/', '', $html);
$html = preg_replace('/<p([^\>]*)><\/p>/', '', $html);
if ($tagvs !== '') {
if (!TCPDF_STATIC::empty_string($tagvs)) {
// set vertical space for some XHTML tags
$tagvspaces = $tagvs;
}
@@ -2133,7 +2141,7 @@ class TCPDF_STATIC {
/**
* Read a 4-byte (32 bit) integer from file.
* @param string $f file name.
* @param resource $f file resource.
* @return int 4-byte integer
* @public static
*/