mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-04-08 17:15:08 +02:00
commit
45c95778ae
@ -106,7 +106,7 @@ Icinga CLI
|
|||||||
|
|
||||||
|
|
||||||
%package vendor-dompdf
|
%package vendor-dompdf
|
||||||
Version: 0.6.1
|
Version: 0.6.2
|
||||||
Release: 1%{?dist}
|
Release: 1%{?dist}
|
||||||
Summary: Icinga Web 2 vendor library dompdf
|
Summary: Icinga Web 2 vendor library dompdf
|
||||||
Group: Development/Libraries
|
Group: Development/Libraries
|
||||||
|
6
library/vendor/dompdf/SOURCE
vendored
6
library/vendor/dompdf/SOURCE
vendored
@ -1,6 +1,6 @@
|
|||||||
curl https://codeload.github.com/dompdf/dompdf/tar.gz/v0.6.1 -o dompdf-0.6.1.tar.gz
|
curl https://codeload.github.com/dompdf/dompdf/tar.gz/v0.6.2 -o dompdf-0.6.2.tar.gz
|
||||||
tar xzf dompdf-0.6.1.tar.gz --strip-components 1 dompdf-0.6.1/{include/*.php,lib,dompdf*.php,LICENSE.LGPL}
|
tar xzf dompdf-0.6.2.tar.gz --strip-components 1 --wildcards dompdf-0.6.2/{include/\*.php,lib,dompdf\*.php,LICENSE.LGPL}
|
||||||
rm dompdf-0.6.1.tar.gz
|
rm dompdf-0.6.2.tar.gz
|
||||||
mv LICENSE.LGPL LICENSE
|
mv LICENSE.LGPL LICENSE
|
||||||
|
|
||||||
curl https://codeload.github.com/PhenX/php-font-lib/tar.gz/0.4 -o php-font-lib-0.4.tar.gz
|
curl https://codeload.github.com/PhenX/php-font-lib/tar.gz/0.4 -o php-font-lib-0.4.tar.gz
|
||||||
|
20
library/vendor/dompdf/dompdf.php
vendored
20
library/vendor/dompdf/dompdf.php
vendored
@ -129,6 +129,8 @@ global $_dompdf_show_warnings, $_dompdf_debug, $_DOMPDF_DEBUG_TYPES;
|
|||||||
$sapi = php_sapi_name();
|
$sapi = php_sapi_name();
|
||||||
$options = array();
|
$options = array();
|
||||||
|
|
||||||
|
$dompdf = new DOMPDF();
|
||||||
|
|
||||||
switch ( $sapi ) {
|
switch ( $sapi ) {
|
||||||
|
|
||||||
case "cli":
|
case "cli":
|
||||||
@ -168,7 +170,7 @@ switch ( $sapi ) {
|
|||||||
if ( $file === "-" )
|
if ( $file === "-" )
|
||||||
$outfile = "dompdf_out.pdf";
|
$outfile = "dompdf_out.pdf";
|
||||||
else
|
else
|
||||||
$outfile = str_ireplace(array(".html", ".htm", ".php"), "", $file) . ".pdf";
|
$outfile = str_ireplace(array(".html", ".htm"), "", $file) . ".pdf";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( isset($opts["v"]) )
|
if ( isset($opts["v"]) )
|
||||||
@ -193,6 +195,8 @@ switch ( $sapi ) {
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
||||||
|
$dompdf->set_option('enable_php', false);
|
||||||
|
|
||||||
if ( isset($_GET["input_file"]) )
|
if ( isset($_GET["input_file"]) )
|
||||||
$file = rawurldecode($_GET["input_file"]);
|
$file = rawurldecode($_GET["input_file"]);
|
||||||
else
|
else
|
||||||
@ -219,26 +223,12 @@ switch ( $sapi ) {
|
|||||||
|
|
||||||
$file_parts = explode_url($file);
|
$file_parts = explode_url($file);
|
||||||
|
|
||||||
/* Check to see if the input file is local and, if so, that the base path falls within that specified by DOMDPF_CHROOT */
|
|
||||||
if(($file_parts['protocol'] == '' || $file_parts['protocol'] === 'file://')) {
|
|
||||||
$file = realpath($file);
|
|
||||||
if ( strpos($file, DOMPDF_CHROOT) !== 0 ) {
|
|
||||||
throw new DOMPDF_Exception("Permission denied on $file. The file could not be found under the directory specified by DOMPDF_CHROOT.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if($file_parts['protocol'] === 'php://') {
|
|
||||||
throw new DOMPDF_Exception("Permission denied on $file. This script does not allow PHP streams.");
|
|
||||||
}
|
|
||||||
|
|
||||||
$outfile = "dompdf_out.pdf"; # Don't allow them to set the output file
|
$outfile = "dompdf_out.pdf"; # Don't allow them to set the output file
|
||||||
$save_file = false; # Don't save the file
|
$save_file = false; # Don't save the file
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$dompdf = new DOMPDF();
|
|
||||||
|
|
||||||
if ( $file === "-" ) {
|
if ( $file === "-" ) {
|
||||||
$str = "";
|
$str = "";
|
||||||
while ( !feof(STDIN) )
|
while ( !feof(STDIN) )
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
// Please refer to dompdf_config.inc.php for details on each configuration option.
|
||||||
|
|
||||||
//define("DOMPDF_TEMP_DIR", "/tmp");
|
//define("DOMPDF_TEMP_DIR", "/tmp");
|
||||||
//define("DOMPDF_CHROOT", DOMPDF_DIR);
|
|
||||||
//define("DOMPDF_FONT_DIR", DOMPDF_DIR."/lib/fonts/");
|
//define("DOMPDF_FONT_DIR", DOMPDF_DIR."/lib/fonts/");
|
||||||
//define("DOMPDF_FONT_CACHE", DOMPDF_DIR."/lib/fonts/");
|
//define("DOMPDF_FONT_CACHE", DOMPDF_DIR."/lib/fonts/");
|
||||||
//define("DOMPDF_UNICODE_ENABLED", true);
|
//define("DOMPDF_UNICODE_ENABLED", true);
|
||||||
@ -9,8 +10,6 @@
|
|||||||
//define("DOMPDF_DEFAULT_PAPER_SIZE", "letter");
|
//define("DOMPDF_DEFAULT_PAPER_SIZE", "letter");
|
||||||
//define("DOMPDF_DEFAULT_FONT", "serif");
|
//define("DOMPDF_DEFAULT_FONT", "serif");
|
||||||
//define("DOMPDF_DPI", 72);
|
//define("DOMPDF_DPI", 72);
|
||||||
//define("DOMPDF_ENABLE_PHP", true);
|
|
||||||
//define("DOMPDF_ENABLE_REMOTE", true);
|
|
||||||
define("DOMPDF_ENABLE_CSS_FLOAT", true);
|
define("DOMPDF_ENABLE_CSS_FLOAT", true);
|
||||||
//define("DOMPDF_ENABLE_JAVASCRIPT", false);
|
//define("DOMPDF_ENABLE_JAVASCRIPT", false);
|
||||||
//define("DEBUGPNG", true);
|
//define("DEBUGPNG", true);
|
||||||
@ -26,6 +25,17 @@ define("DOMPDF_ENABLE_CSS_FLOAT", true);
|
|||||||
//define("DOMPDF_ENABLE_HTML5PARSER", true);
|
//define("DOMPDF_ENABLE_HTML5PARSER", true);
|
||||||
//define("DOMPDF_ENABLE_FONTSUBSETTING", true);
|
//define("DOMPDF_ENABLE_FONTSUBSETTING", true);
|
||||||
|
|
||||||
// DOMPDF authentication
|
// Authentication for the dompdf/www
|
||||||
//define("DOMPDF_ADMIN_USERNAME", "user");
|
//define("DOMPDF_ADMIN_USERNAME", "user");
|
||||||
//define("DOMPDF_ADMIN_PASSWORD", "password");
|
//define("DOMPDF_ADMIN_PASSWORD", "password");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attention!
|
||||||
|
* The following settings may increase the risk of system exploit.
|
||||||
|
* Do not change these settings without understanding the consequences.
|
||||||
|
* Additional documentation is available on the dompdf wiki at:
|
||||||
|
* https://github.com/dompdf/dompdf/wiki
|
||||||
|
*/
|
||||||
|
//define("DOMPDF_CHROOT", DOMPDF_DIR);
|
||||||
|
//define("DOMPDF_ENABLE_PHP", false);
|
||||||
|
//define("DOMPDF_ENABLE_REMOTE", false);
|
||||||
|
8
library/vendor/dompdf/dompdf_config.inc.php
vendored
8
library/vendor/dompdf/dompdf_config.inc.php
vendored
@ -5,7 +5,7 @@
|
|||||||
* @author Benj Carson <benjcarson@digitaljunkies.ca>
|
* @author Benj Carson <benjcarson@digitaljunkies.ca>
|
||||||
* @author Helmut Tischer <htischer@weihenstephan.org>
|
* @author Helmut Tischer <htischer@weihenstephan.org>
|
||||||
* @author Fabien Ménager <fabien.menager@gmail.com>
|
* @author Fabien Ménager <fabien.menager@gmail.com>
|
||||||
* @autho Brian Sweeney <eclecticgeek@gmail.com>
|
* @author Brian Sweeney <eclecticgeek@gmail.com>
|
||||||
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
|
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -246,9 +246,11 @@ def("DOMPDF_DPI", 96);
|
|||||||
* If this setting is set to true then DOMPDF will automatically evaluate
|
* If this setting is set to true then DOMPDF will automatically evaluate
|
||||||
* inline PHP contained within <script type="text/php"> ... </script> tags.
|
* inline PHP contained within <script type="text/php"> ... </script> tags.
|
||||||
*
|
*
|
||||||
|
* Attention!
|
||||||
* Enabling this for documents you do not trust (e.g. arbitrary remote html
|
* Enabling this for documents you do not trust (e.g. arbitrary remote html
|
||||||
* pages) is a security risk. Set this option to false if you wish to process
|
* pages) is a security risk. Inline scripts are run with the same level of
|
||||||
* untrusted documents.
|
* system access available to dompdf. Set this option to false (recommended)
|
||||||
|
* if you wish to process untrusted documents.
|
||||||
*
|
*
|
||||||
* @var bool
|
* @var bool
|
||||||
*/
|
*/
|
||||||
|
@ -100,7 +100,7 @@ abstract class Abstract_Renderer {
|
|||||||
//Therefore read dimension directly from file, instead of creating gd object first.
|
//Therefore read dimension directly from file, instead of creating gd object first.
|
||||||
//$img_w = imagesx($src); $img_h = imagesy($src);
|
//$img_w = imagesx($src); $img_h = imagesy($src);
|
||||||
|
|
||||||
list($img_w, $img_h) = dompdf_getimagesize($img);
|
list($img_w, $img_h) = dompdf_getimagesize($img, $this->_dompdf->get_http_context());
|
||||||
if (!isset($img_w) || $img_w == 0 || !isset($img_h) || $img_h == 0) {
|
if (!isset($img_w) || $img_w == 0 || !isset($img_h) || $img_h == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -604,7 +604,7 @@ class CPDF_Adapter implements Canvas {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function image($img, $x, $y, $w, $h, $resolution = "normal") {
|
function image($img, $x, $y, $w, $h, $resolution = "normal") {
|
||||||
list($width, $height, $type) = dompdf_getimagesize($img);
|
list($width, $height, $type) = dompdf_getimagesize($img, $this->_dompdf->get_http_context());
|
||||||
|
|
||||||
$debug_png = $this->_dompdf->get_option("debug_png");
|
$debug_png = $this->_dompdf->get_option("debug_png");
|
||||||
|
|
||||||
|
40
library/vendor/dompdf/include/dompdf.cls.php
vendored
40
library/vendor/dompdf/include/dompdf.cls.php
vendored
@ -184,6 +184,25 @@ class DOMPDF {
|
|||||||
* @var bool
|
* @var bool
|
||||||
*/
|
*/
|
||||||
private $_quirksmode = false;
|
private $_quirksmode = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Protocol whitelist
|
||||||
|
*
|
||||||
|
* Protocols and PHP wrappers allowed in URLs. Full support is not
|
||||||
|
* guarantee for the protocols/wrappers contained in this array.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
private $_allowed_protocols = array(null, "", "file://", "http://", "https://");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Local file extension whitelist
|
||||||
|
*
|
||||||
|
* File extensions supported by dompdf for local files.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
private $_allowed_local_file_extensions = array("htm", "html");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The list of built-in fonts
|
* The list of built-in fonts
|
||||||
@ -474,6 +493,10 @@ class DOMPDF {
|
|||||||
list($this->_protocol, $this->_base_host, $this->_base_path) = explode_url($file);
|
list($this->_protocol, $this->_base_host, $this->_base_path) = explode_url($file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( !in_array($this->_protocol, $this->_allowed_protocols) ) {
|
||||||
|
throw new DOMPDF_Exception("Permission denied on $file. The communication protocol is not supported.");
|
||||||
|
}
|
||||||
|
|
||||||
if ( !$this->get_option("enable_remote") && ($this->_protocol != "" && $this->_protocol !== "file://" ) ) {
|
if ( !$this->get_option("enable_remote") && ($this->_protocol != "" && $this->_protocol !== "file://" ) ) {
|
||||||
throw new DOMPDF_Exception("Remote file requested, but DOMPDF_ENABLE_REMOTE is false.");
|
throw new DOMPDF_Exception("Remote file requested, but DOMPDF_ENABLE_REMOTE is false.");
|
||||||
}
|
}
|
||||||
@ -482,23 +505,24 @@ class DOMPDF {
|
|||||||
|
|
||||||
// Get the full path to $file, returns false if the file doesn't exist
|
// Get the full path to $file, returns false if the file doesn't exist
|
||||||
$realfile = realpath($file);
|
$realfile = realpath($file);
|
||||||
if ( !$realfile ) {
|
|
||||||
throw new DOMPDF_Exception("File '$file' not found.");
|
|
||||||
}
|
|
||||||
|
|
||||||
$chroot = $this->get_option("chroot");
|
$chroot = $this->get_option("chroot");
|
||||||
if ( strpos($realfile, $chroot) !== 0 ) {
|
if ( strpos($realfile, $chroot) !== 0 ) {
|
||||||
throw new DOMPDF_Exception("Permission denied on $file. The file could not be found under the directory specified by DOMPDF_CHROOT.");
|
throw new DOMPDF_Exception("Permission denied on $file. The file could not be found under the directory specified by DOMPDF_CHROOT.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Exclude dot files (e.g. .htaccess)
|
$ext = pathinfo($realfile, PATHINFO_EXTENSION);
|
||||||
if ( substr(basename($realfile), 0, 1) === "." ) {
|
if (!in_array($ext, $this->_allowed_local_file_extensions)) {
|
||||||
throw new DOMPDF_Exception("Permission denied on $file.");
|
throw new DOMPDF_Exception("Permission denied on $file.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( !$realfile ) {
|
||||||
|
throw new DOMPDF_Exception("File '$file' not found.");
|
||||||
|
}
|
||||||
|
|
||||||
$file = $realfile;
|
$file = $realfile;
|
||||||
}
|
}
|
||||||
|
|
||||||
$contents = file_get_contents($file, null, $this->_http_context);
|
$contents = file_get_contents($file, null, $this->_http_context);
|
||||||
$encoding = null;
|
$encoding = null;
|
||||||
|
|
||||||
|
@ -217,10 +217,18 @@ class Font_Metrics {
|
|||||||
*/
|
*/
|
||||||
static function save_font_families() {
|
static function save_font_families() {
|
||||||
// replace the path to the DOMPDF font directories with the corresponding constants (allows for more portability)
|
// replace the path to the DOMPDF font directories with the corresponding constants (allows for more portability)
|
||||||
$cache_data = var_export(self::$_font_lookup, true);
|
$cache_data = sprintf("<?php return array (%s", PHP_EOL);
|
||||||
$cache_data = str_replace('\''.DOMPDF_FONT_DIR , 'DOMPDF_FONT_DIR . \'' , $cache_data);
|
foreach (self::$_font_lookup as $family => $variants) {
|
||||||
$cache_data = str_replace('\''.DOMPDF_DIR , 'DOMPDF_DIR . \'' , $cache_data);
|
$cache_data .= sprintf(" '%s' => array(%s", addslashes($family), PHP_EOL);
|
||||||
$cache_data = "<"."?php return $cache_data ?".">";
|
foreach ($variants as $variant => $path) {
|
||||||
|
$path = sprintf("'%s'", $path);
|
||||||
|
$path = str_replace('\'' . DOMPDF_FONT_DIR , 'DOMPDF_FONT_DIR . \'' , $path);
|
||||||
|
$path = str_replace('\'' . DOMPDF_DIR , 'DOMPDF_DIR . \'' , $path);
|
||||||
|
$cache_data .= sprintf(" '%s' => %s,%s", $variant, $path, PHP_EOL);
|
||||||
|
}
|
||||||
|
$cache_data .= sprintf(" ),%s", PHP_EOL);
|
||||||
|
}
|
||||||
|
$cache_data .= ") ?>";
|
||||||
file_put_contents(self::CACHE_FILE, $cache_data);
|
file_put_contents(self::CACHE_FILE, $cache_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -249,13 +257,18 @@ class Font_Metrics {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
self::$_font_lookup = require_once self::CACHE_FILE;
|
$cache_data = require_once self::CACHE_FILE;
|
||||||
|
|
||||||
// If the font family cache is still in the old format
|
// If the font family cache is still in the old format
|
||||||
if ( self::$_font_lookup === 1 ) {
|
if ( self::$_font_lookup === 1 ) {
|
||||||
$cache_data = file_get_contents(self::CACHE_FILE);
|
$cache_data = file_get_contents(self::CACHE_FILE);
|
||||||
file_put_contents(self::CACHE_FILE, "<"."?php return $cache_data ?".">");
|
file_put_contents(self::CACHE_FILE, "<"."?php return $cache_data ?".">");
|
||||||
self::$_font_lookup = require_once self::CACHE_FILE;
|
$cache_data = require_once self::CACHE_FILE;
|
||||||
|
}
|
||||||
|
|
||||||
|
self::$_font_lookup = array();
|
||||||
|
foreach ($cache_data as $key => $value) {
|
||||||
|
self::$_font_lookup[stripslashes($key)] = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Merge provided fonts
|
// Merge provided fonts
|
||||||
@ -318,7 +331,7 @@ class Font_Metrics {
|
|||||||
self::$_font_lookup[mb_strtolower($fontname)] = $entry;
|
self::$_font_lookup[mb_strtolower($fontname)] = $entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function register_font($style, $remote_file) {
|
static function register_font($style, $remote_file, $context = null) {
|
||||||
$fontname = mb_strtolower($style["family"]);
|
$fontname = mb_strtolower($style["family"]);
|
||||||
$families = Font_Metrics::get_font_families();
|
$families = Font_Metrics::get_font_families();
|
||||||
|
|
||||||
@ -328,6 +341,7 @@ class Font_Metrics {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$local_file = DOMPDF_FONT_DIR . md5($remote_file);
|
$local_file = DOMPDF_FONT_DIR . md5($remote_file);
|
||||||
|
$local_temp_file = DOMPDF_TEMP_DIR . "/" . md5($remote_file);
|
||||||
$cache_entry = $local_file;
|
$cache_entry = $local_file;
|
||||||
$local_file .= ".ttf";
|
$local_file .= ".ttf";
|
||||||
|
|
||||||
@ -336,23 +350,28 @@ class Font_Metrics {
|
|||||||
if ( !isset($entry[$style_string]) ) {
|
if ( !isset($entry[$style_string]) ) {
|
||||||
$entry[$style_string] = $cache_entry;
|
$entry[$style_string] = $cache_entry;
|
||||||
|
|
||||||
Font_Metrics::set_font_family($fontname, $entry);
|
|
||||||
|
|
||||||
// Download the remote file
|
// Download the remote file
|
||||||
if ( !is_file($local_file) ) {
|
file_put_contents($local_temp_file, file_get_contents($remote_file, null, $context));
|
||||||
file_put_contents($local_file, file_get_contents($remote_file));
|
|
||||||
}
|
|
||||||
|
|
||||||
$font = Font::load($local_file);
|
$font = Font::load($local_temp_file);
|
||||||
|
|
||||||
if (!$font) {
|
if (!$font) {
|
||||||
|
unlink($local_temp_file);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$font->parse();
|
$font->parse();
|
||||||
$font->saveAdobeFontMetrics("$cache_entry.ufm");
|
$font->saveAdobeFontMetrics("$cache_entry.ufm");
|
||||||
|
|
||||||
|
unlink($local_temp_file);
|
||||||
|
|
||||||
|
if ( !file_exists("$cache_entry.ufm") ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Save the changes
|
// Save the changes
|
||||||
|
file_put_contents($local_file, file_get_contents($remote_file, null, $context));
|
||||||
|
Font_Metrics::set_font_family($fontname, $entry);
|
||||||
Font_Metrics::save_font_families();
|
Font_Metrics::save_font_families();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
70
library/vendor/dompdf/include/functions.inc.php
vendored
70
library/vendor/dompdf/include/functions.inc.php
vendored
@ -128,47 +128,45 @@ function d($mixed) {
|
|||||||
* is appended (o.k. also for Windows)
|
* is appended (o.k. also for Windows)
|
||||||
*/
|
*/
|
||||||
function build_url($protocol, $host, $base_path, $url) {
|
function build_url($protocol, $host, $base_path, $url) {
|
||||||
if ( strlen($url) == 0 ) {
|
$protocol = mb_strtolower($protocol);
|
||||||
|
if (strlen($url) == 0) {
|
||||||
//return $protocol . $host . rtrim($base_path, "/\\") . "/";
|
//return $protocol . $host . rtrim($base_path, "/\\") . "/";
|
||||||
return $protocol . $host . $base_path;
|
return $protocol . $host . $base_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Is the url already fully qualified or a Data URI?
|
// Is the url already fully qualified or a Data URI?
|
||||||
if ( mb_strpos($url, "://") !== false || mb_strpos($url, "data:") === 0 ) {
|
if (mb_strpos($url, "://") !== false || mb_strpos($url, "data:") === 0) {
|
||||||
return $url;
|
return $url;
|
||||||
}
|
}
|
||||||
|
|
||||||
$ret = $protocol;
|
$ret = $protocol;
|
||||||
|
if (!in_array(mb_strtolower($protocol), array("http://", "https://", "ftp://", "ftps://"))) {
|
||||||
if ( !in_array(mb_strtolower($protocol), array("http://", "https://", "ftp://", "ftps://")) ) {
|
|
||||||
//On Windows local file, an abs path can begin also with a '\' or a drive letter and colon
|
//On Windows local file, an abs path can begin also with a '\' or a drive letter and colon
|
||||||
//drive: followed by a relative path would be a drive specific default folder.
|
//drive: followed by a relative path would be a drive specific default folder.
|
||||||
//not known in php app code, treat as abs path
|
//not known in php app code, treat as abs path
|
||||||
//($url[1] !== ':' || ($url[2]!=='\\' && $url[2]!=='/'))
|
//($url[1] !== ':' || ($url[2]!=='\\' && $url[2]!=='/'))
|
||||||
if ( $url[0] !== '/' && (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN' || ($url[0] !== '\\' && $url[1] !== ':')) ) {
|
if ($url[0] !== '/' && (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN' || ($url[0] !== '\\' && $url[1] !== ':'))) {
|
||||||
// For rel path and local acess we ignore the host, and run the path through realpath()
|
// For rel path and local acess we ignore the host, and run the path through realpath()
|
||||||
$ret .= realpath($base_path).'/';
|
$ret .= realpath($base_path) . '/';
|
||||||
}
|
}
|
||||||
$ret .= $url;
|
$ret .= $url;
|
||||||
$ret = preg_replace('/\?(.*)$/', "", $ret);
|
$ret = preg_replace('/\?(.*)$/', "", $ret);
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
// Protocol relative urls (e.g. "//example.org/style.css")
|
||||||
//remote urls with backslash in html/css are not really correct, but lets be genereous
|
if (strpos($url, '//') === 0) {
|
||||||
if ( $url[0] === '/' || $url[0] === '\\' ) {
|
$ret .= substr($url, 2);
|
||||||
|
//remote urls with backslash in html/css are not really correct, but lets be genereous
|
||||||
|
} elseif ($url[0] === '/' || $url[0] === '\\') {
|
||||||
// Absolute path
|
// Absolute path
|
||||||
$ret .= $host . $url;
|
$ret .= $host . $url;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// Relative path
|
// Relative path
|
||||||
//$base_path = $base_path !== "" ? rtrim($base_path, "/\\") . "/" : "";
|
//$base_path = $base_path !== "" ? rtrim($base_path, "/\\") . "/" : "";
|
||||||
$ret .= $host . $base_path . $url;
|
$ret .= $host . $base_path . $url;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $ret;
|
return $ret;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* parse a full url or pathname and return an array(protocol, host, path,
|
* parse a full url or pathname and return an array(protocol, host, path,
|
||||||
* file + query + fragment)
|
* file + query + fragment)
|
||||||
@ -183,7 +181,10 @@ function explode_url($url) {
|
|||||||
$file = "";
|
$file = "";
|
||||||
|
|
||||||
$arr = parse_url($url);
|
$arr = parse_url($url);
|
||||||
|
if ( isset($arr["scheme"])) {
|
||||||
|
$arr["scheme"] == mb_strtolower($arr["scheme"]);
|
||||||
|
}
|
||||||
|
|
||||||
// Exclude windows drive letters...
|
// Exclude windows drive letters...
|
||||||
if ( isset($arr["scheme"]) && $arr["scheme"] !== "file" && strlen($arr["scheme"]) > 1 ) {
|
if ( isset($arr["scheme"]) && $arr["scheme"] !== "file" && strlen($arr["scheme"]) > 1 ) {
|
||||||
$protocol = $arr["scheme"] . "://";
|
$protocol = $arr["scheme"] . "://";
|
||||||
@ -229,7 +230,7 @@ function explode_url($url) {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
$i = mb_strpos($url, "file://");
|
$i = mb_stripos($url, "file://");
|
||||||
if ( $i !== false ) {
|
if ( $i !== false ) {
|
||||||
$url = mb_substr($url, $i + 7);
|
$url = mb_substr($url, $i + 7);
|
||||||
}
|
}
|
||||||
@ -400,6 +401,12 @@ if (!extension_loaded('mbstring')) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!function_exists('mb_stripos')) {
|
||||||
|
function mb_stripos($haystack, $needle, $offset = 0) {
|
||||||
|
return stripos($haystack, $needle, $offset);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!function_exists('mb_strrpos')) {
|
if (!function_exists('mb_strrpos')) {
|
||||||
function mb_strrpos($haystack, $needle, $offset = 0) {
|
function mb_strrpos($haystack, $needle, $offset = 0) {
|
||||||
return strrpos($haystack, $needle, $offset);
|
return strrpos($haystack, $needle, $offset);
|
||||||
@ -748,7 +755,7 @@ function imagecreatefrombmp($filename) {
|
|||||||
* @param string $filename
|
* @param string $filename
|
||||||
* @return array The same format as getimagesize($filename)
|
* @return array The same format as getimagesize($filename)
|
||||||
*/
|
*/
|
||||||
function dompdf_getimagesize($filename) {
|
function dompdf_getimagesize($filename, $context = null) {
|
||||||
static $cache = array();
|
static $cache = array();
|
||||||
|
|
||||||
if ( isset($cache[$filename]) ) {
|
if ( isset($cache[$filename]) ) {
|
||||||
@ -758,7 +765,7 @@ function dompdf_getimagesize($filename) {
|
|||||||
list($width, $height, $type) = getimagesize($filename);
|
list($width, $height, $type) = getimagesize($filename);
|
||||||
|
|
||||||
if ( $width == null || $height == null ) {
|
if ( $width == null || $height == null ) {
|
||||||
$data = file_get_contents($filename, null, null, 0, 26);
|
$data = file_get_contents($filename, null, $context, 0, 26);
|
||||||
|
|
||||||
if ( substr($data, 0, 2) === "BM" ) {
|
if ( substr($data, 0, 2) === "BM" ) {
|
||||||
$meta = unpack('vtype/Vfilesize/Vreserved/Voffset/Vheadersize/Vwidth/Vheight', $data);
|
$meta = unpack('vtype/Vfilesize/Vreserved/Voffset/Vheadersize/Vwidth/Vheight', $data);
|
||||||
@ -1005,31 +1012,6 @@ else {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( function_exists("curl_init") ) {
|
|
||||||
function DOMPDF_fetch_url($url, &$headers = null) {
|
|
||||||
$ch = curl_init($url);
|
|
||||||
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
|
|
||||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
|
|
||||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
||||||
curl_setopt($ch, CURLOPT_HEADER, true);
|
|
||||||
|
|
||||||
$data = curl_exec($ch);
|
|
||||||
$raw_headers = substr($data, 0, curl_getinfo($ch, CURLINFO_HEADER_SIZE));
|
|
||||||
$headers = preg_split("/[\n\r]+/", trim($raw_headers));
|
|
||||||
$data = substr($data, curl_getinfo($ch, CURLINFO_HEADER_SIZE));
|
|
||||||
curl_close($ch);
|
|
||||||
|
|
||||||
return $data;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
function DOMPDF_fetch_url($url, &$headers = null) {
|
|
||||||
$data = file_get_contents($url);
|
|
||||||
$headers = $http_response_header;
|
|
||||||
|
|
||||||
return $data;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Affect null to the unused objects
|
* Affect null to the unused objects
|
||||||
|
@ -553,7 +553,7 @@ class GD_Adapter implements Canvas {
|
|||||||
* @internal param string $img_type the type (e.g. extension) of the image
|
* @internal param string $img_type the type (e.g. extension) of the image
|
||||||
*/
|
*/
|
||||||
function image($img_url, $x, $y, $w, $h, $resolution = "normal") {
|
function image($img_url, $x, $y, $w, $h, $resolution = "normal") {
|
||||||
$img_type = Image_Cache::detect_type($img_url);
|
$img_type = Image_Cache::detect_type($img_url, $this->_dompdf->get_http_context());
|
||||||
$img_ext = Image_Cache::type_to_ext($img_type);
|
$img_ext = Image_Cache::type_to_ext($img_type);
|
||||||
|
|
||||||
if ( !$img_ext ) {
|
if ( !$img_ext ) {
|
||||||
|
@ -45,6 +45,7 @@ class Image_Cache {
|
|||||||
* @return array An array with two elements: The local path to the image and the image extension
|
* @return array An array with two elements: The local path to the image and the image extension
|
||||||
*/
|
*/
|
||||||
static function resolve_url($url, $protocol, $host, $base_path, DOMPDF $dompdf) {
|
static function resolve_url($url, $protocol, $host, $base_path, DOMPDF $dompdf) {
|
||||||
|
$protocol = mb_strtolower($protocol);
|
||||||
$parsed_url = explode_url($url);
|
$parsed_url = explode_url($url);
|
||||||
$message = null;
|
$message = null;
|
||||||
|
|
||||||
@ -84,7 +85,7 @@ class Image_Cache {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
set_error_handler("record_warnings");
|
set_error_handler("record_warnings");
|
||||||
$image = file_get_contents($full_url);
|
$image = file_get_contents($full_url, null, $dompdf->get_http_context());
|
||||||
restore_error_handler();
|
restore_error_handler();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,7 +119,7 @@ class Image_Cache {
|
|||||||
|
|
||||||
// Check is the file is an image
|
// Check is the file is an image
|
||||||
else {
|
else {
|
||||||
list($width, $height, $type) = dompdf_getimagesize($resolved_url);
|
list($width, $height, $type) = dompdf_getimagesize($resolved_url, $dompdf->get_http_context());
|
||||||
|
|
||||||
// Known image type
|
// Known image type
|
||||||
if ( $width && $height && in_array($type, array(IMAGETYPE_GIF, IMAGETYPE_PNG, IMAGETYPE_JPEG, IMAGETYPE_BMP)) ) {
|
if ( $width && $height && in_array($type, array(IMAGETYPE_GIF, IMAGETYPE_PNG, IMAGETYPE_JPEG, IMAGETYPE_BMP)) ) {
|
||||||
@ -138,7 +139,8 @@ class Image_Cache {
|
|||||||
catch(DOMPDF_Image_Exception $e) {
|
catch(DOMPDF_Image_Exception $e) {
|
||||||
$resolved_url = self::$broken_image;
|
$resolved_url = self::$broken_image;
|
||||||
$type = IMAGETYPE_PNG;
|
$type = IMAGETYPE_PNG;
|
||||||
$message = $e->getMessage()." \n $url";
|
$message = "Image not found or type unknown";
|
||||||
|
$_dompdf_warnings[] = $e->getMessage()." :: $url";
|
||||||
}
|
}
|
||||||
|
|
||||||
return array($resolved_url, $type, $message);
|
return array($resolved_url, $type, $message);
|
||||||
@ -159,8 +161,8 @@ class Image_Cache {
|
|||||||
self::$_cache = array();
|
self::$_cache = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
static function detect_type($file) {
|
static function detect_type($file, $context = null) {
|
||||||
list(, , $type) = dompdf_getimagesize($file);
|
list(, , $type) = dompdf_getimagesize($file, $context);
|
||||||
return $type;
|
return $type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ class Image_Frame_Reflower extends Frame_Reflower {
|
|||||||
function get_min_max_width() {
|
function get_min_max_width() {
|
||||||
if (DEBUGPNG) {
|
if (DEBUGPNG) {
|
||||||
// Determine the image's size. Time consuming. Only when really needed?
|
// Determine the image's size. Time consuming. Only when really needed?
|
||||||
list($img_width, $img_height) = dompdf_getimagesize($this->_frame->get_image_url());
|
list($img_width, $img_height) = dompdf_getimagesize($this->_frame->get_image_url(), $this->get_dompdf()->get_http_context());
|
||||||
print "get_min_max_width() ".
|
print "get_min_max_width() ".
|
||||||
$this->_frame->get_style()->width.' '.
|
$this->_frame->get_style()->width.' '.
|
||||||
$this->_frame->get_style()->height.';'.
|
$this->_frame->get_style()->height.';'.
|
||||||
@ -104,7 +104,7 @@ class Image_Frame_Reflower extends Frame_Reflower {
|
|||||||
|
|
||||||
if ($width == 0 || $height == 0) {
|
if ($width == 0 || $height == 0) {
|
||||||
// Determine the image's size. Time consuming. Only when really needed!
|
// Determine the image's size. Time consuming. Only when really needed!
|
||||||
list($img_width, $img_height) = dompdf_getimagesize($this->_frame->get_image_url());
|
list($img_width, $img_height) = dompdf_getimagesize($this->_frame->get_image_url(), $this->get_dompdf()->get_http_context());
|
||||||
|
|
||||||
// don't treat 0 as error. Can be downscaled or can be catched elsewhere if image not readable.
|
// don't treat 0 as error. Can be downscaled or can be catched elsewhere if image not readable.
|
||||||
// Resample according to px per inch
|
// Resample according to px per inch
|
||||||
|
@ -48,7 +48,7 @@ class List_Bullet_Image_Frame_Decorator extends Frame_Decorator {
|
|||||||
$frame->get_node()->setAttribute("src", $url);
|
$frame->get_node()->setAttribute("src", $url);
|
||||||
$this->_img = new Image_Frame_Decorator($frame, $dompdf);
|
$this->_img = new Image_Frame_Decorator($frame, $dompdf);
|
||||||
parent::__construct($this->_img, $dompdf);
|
parent::__construct($this->_img, $dompdf);
|
||||||
list($width, $height) = dompdf_getimagesize($this->_img->get_image_url());
|
list($width, $height) = dompdf_getimagesize($this->_img->get_image_url(), $dompdf->get_http_context());
|
||||||
|
|
||||||
// Resample the bullet image to be consistent with 'auto' sized images
|
// Resample the bullet image to be consistent with 'auto' sized images
|
||||||
// See also Image_Frame_Reflower::get_min_max_width
|
// See also Image_Frame_Reflower::get_min_max_width
|
||||||
|
@ -141,7 +141,7 @@ class List_Bullet_Renderer extends Abstract_Renderer {
|
|||||||
// Tested php ver: value measured in px, suffix "px" not in value: rtrim unnecessary.
|
// Tested php ver: value measured in px, suffix "px" not in value: rtrim unnecessary.
|
||||||
//$w = $frame->get_width();
|
//$w = $frame->get_width();
|
||||||
//$h = $frame->get_height();
|
//$h = $frame->get_height();
|
||||||
list($width, $height) = dompdf_getimagesize($img);
|
list($width, $height) = dompdf_getimagesize($img, $this->_dompdf->get_http_context());
|
||||||
$dpi = $this->_dompdf->get_option("dpi");
|
$dpi = $this->_dompdf->get_option("dpi");
|
||||||
$w = ((float)rtrim($width, "px") * 72) / $dpi;
|
$w = ((float)rtrim($width, "px") * 72) / $dpi;
|
||||||
$h = ((float)rtrim($height, "px") * 72) / $dpi;
|
$h = ((float)rtrim($height, "px") * 72) / $dpi;
|
||||||
|
@ -770,7 +770,7 @@ class PDFLib_Adapter implements Canvas {
|
|||||||
$w = (int)$w;
|
$w = (int)$w;
|
||||||
$h = (int)$h;
|
$h = (int)$h;
|
||||||
|
|
||||||
$img_type = Image_Cache::detect_type($img_url);
|
$img_type = Image_Cache::detect_type($img_url, $this->_dompdf->get_http_context());
|
||||||
$img_ext = Image_Cache::type_to_ext($img_type);
|
$img_ext = Image_Cache::type_to_ext($img_type);
|
||||||
|
|
||||||
if ( !isset($this->_imgs[$img_url]) ) {
|
if ( !isset($this->_imgs[$img_url]) ) {
|
||||||
|
@ -1250,7 +1250,7 @@ class Stylesheet {
|
|||||||
"path" => build_url($this->_protocol, $this->_base_host, $this->_base_path, $src[2][$i]),
|
"path" => build_url($this->_protocol, $this->_base_host, $this->_base_path, $src[2][$i]),
|
||||||
);
|
);
|
||||||
|
|
||||||
if ( !$source["local"] && in_array($source["format"], array("", "woff", "opentype", "truetype")) ) {
|
if ( !$source["local"] && in_array($source["format"], array("", "truetype")) ) {
|
||||||
$valid_sources[] = $source;
|
$valid_sources[] = $source;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1268,7 +1268,7 @@ class Stylesheet {
|
|||||||
"style" => $descriptors->font_style,
|
"style" => $descriptors->font_style,
|
||||||
);
|
);
|
||||||
|
|
||||||
Font_Metrics::register_font($style, $valid_sources[0]["path"]);
|
Font_Metrics::register_font($style, $valid_sources[0]["path"], $this->_dompdf->get_http_context());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
6
library/vendor/dompdf/lib/class.pdf.php
vendored
6
library/vendor/dompdf/lib/class.pdf.php
vendored
@ -749,7 +749,7 @@ end
|
|||||||
EOT;
|
EOT;
|
||||||
|
|
||||||
$res = "<</Length " . mb_strlen($stream, '8bit') . " >>\n";
|
$res = "<</Length " . mb_strlen($stream, '8bit') . " >>\n";
|
||||||
$res .= "stream\n" . $stream . "endstream";
|
$res .= "stream\n" . $stream . "\nendstream";
|
||||||
|
|
||||||
$this->objects[$toUnicodeId]['c'] = $res;
|
$this->objects[$toUnicodeId]['c'] = $res;
|
||||||
|
|
||||||
@ -1875,7 +1875,7 @@ EOT;
|
|||||||
$tmp = 'o_'.$v['t'];
|
$tmp = 'o_'.$v['t'];
|
||||||
$cont = $this->$tmp($k, 'out');
|
$cont = $this->$tmp($k, 'out');
|
||||||
$content.= $cont;
|
$content.= $cont;
|
||||||
$xref[] = $pos;
|
$xref[] = $pos+1; //+1 to account for \n at the start of each object
|
||||||
$pos+= mb_strlen($cont, '8bit');
|
$pos+= mb_strlen($cont, '8bit');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2426,7 +2426,7 @@ EOT;
|
|||||||
$flags+= pow(2, 5); // assume non-sybolic
|
$flags+= pow(2, 5); // assume non-sybolic
|
||||||
$list = array(
|
$list = array(
|
||||||
'Ascent' => 'Ascender',
|
'Ascent' => 'Ascender',
|
||||||
'CapHeight' => 'CapHeight',
|
'CapHeight' => 'Ascender', //FIXME: php-font-lib is not grabbing this value, so we'll fake it and use the Ascender value // 'CapHeight'
|
||||||
'MissingWidth' => 'MissingWidth',
|
'MissingWidth' => 'MissingWidth',
|
||||||
'Descent' => 'Descender',
|
'Descent' => 'Descender',
|
||||||
'FontBBox' => 'FontBBox',
|
'FontBBox' => 'FontBBox',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user