From 125ef4751080a2118cb203357d77687699e3eb25 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 11 Jan 2016 12:33:00 +0200 Subject: [ci skip] Bump year to 2016 --- system/libraries/Image_lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'system/libraries/Image_lib.php') diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php index e813efd89..cc865fd81 100644 --- a/system/libraries/Image_lib.php +++ b/system/libraries/Image_lib.php @@ -6,7 +6,7 @@ * * This content is released under the MIT License (MIT) * - * Copyright (c) 2014 - 2015, British Columbia Institute of Technology + * Copyright (c) 2014 - 2016, British Columbia Institute of Technology * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * @package CodeIgniter * @author EllisLab Dev Team * @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/) - * @copyright Copyright (c) 2014 - 2015, British Columbia Institute of Technology (http://bcit.ca/) + * @copyright Copyright (c) 2014 - 2016, British Columbia Institute of Technology (http://bcit.ca/) * @license http://opensource.org/licenses/MIT MIT License * @link http://codeigniter.com * @since Version 1.0.0 -- cgit v1.2.3-24-g4f1b From bd202c91b0e9cf0a8c93bcaa71df9574f5909346 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 11 Jan 2016 12:50:18 +0200 Subject: [ci skip] Update codeigniter.com links to https --- system/libraries/Image_lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'system/libraries/Image_lib.php') diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php index cc865fd81..d3a832415 100644 --- a/system/libraries/Image_lib.php +++ b/system/libraries/Image_lib.php @@ -31,7 +31,7 @@ * @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/) * @copyright Copyright (c) 2014 - 2016, British Columbia Institute of Technology (http://bcit.ca/) * @license http://opensource.org/licenses/MIT MIT License - * @link http://codeigniter.com + * @link https://codeigniter.com * @since Version 1.0.0 * @filesource */ @@ -44,7 +44,7 @@ defined('BASEPATH') OR exit('No direct script access allowed'); * @subpackage Libraries * @category Image_lib * @author EllisLab Dev Team - * @link http://codeigniter.com/user_guide/libraries/image_lib.html + * @link https://codeigniter.com/user_guide/libraries/image_lib.html */ class CI_Image_lib { -- cgit v1.2.3-24-g4f1b From 1924e879b165fb119847a49a7a5eab2f28295fa2 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 11 Jan 2016 12:55:34 +0200 Subject: [ci skip] Update ellislab.com links to https too --- system/libraries/Image_lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/libraries/Image_lib.php') diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php index d3a832415..f594b7125 100644 --- a/system/libraries/Image_lib.php +++ b/system/libraries/Image_lib.php @@ -28,7 +28,7 @@ * * @package CodeIgniter * @author EllisLab Dev Team - * @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/) + * @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/) * @copyright Copyright (c) 2014 - 2016, British Columbia Institute of Technology (http://bcit.ca/) * @license http://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com -- cgit v1.2.3-24-g4f1b From 1be0f05e3f70a369e9e3e5153d0f786c0d2dface Mon Sep 17 00:00:00 2001 From: KN4CK3R Date: Fri, 12 Feb 2016 22:31:15 +0100 Subject: return false when image isn't valid --- system/libraries/Image_lib.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'system/libraries/Image_lib.php') diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php index f594b7125..e3e87f93f 100644 --- a/system/libraries/Image_lib.php +++ b/system/libraries/Image_lib.php @@ -1641,6 +1641,11 @@ class CI_Image_lib { } $vals = getimagesize($path); + if ($vals === FALSE) + { + $this->set_error('imglib_invalid_image'); + return FALSE; + } $types = array(1 => 'gif', 2 => 'jpeg', 3 => 'png'); $mime = (isset($types[$vals[2]])) ? 'image/'.$types[$vals[2]] : 'image/jpg'; -- cgit v1.2.3-24-g4f1b From eac4adfc24d1ad60af2bc3e08222ee7e5858f638 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 22 Mar 2016 11:24:14 +0200 Subject: [ci skip] Validate width, height config values --- system/libraries/Image_lib.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'system/libraries/Image_lib.php') diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php index f594b7125..edd13372d 100644 --- a/system/libraries/Image_lib.php +++ b/system/libraries/Image_lib.php @@ -456,7 +456,7 @@ class CI_Image_lib { { if (property_exists($this, $key)) { - if (in_array($key, array('wm_font_color', 'wm_shadow_color'))) + if (in_array($key, array('wm_font_color', 'wm_shadow_color'), TRUE)) { if (preg_match('/^#?([0-9a-f]{3}|[0-9a-f]{6})$/i', $val, $matches)) { @@ -478,6 +478,10 @@ class CI_Image_lib { continue; } } + elseif (in_array($key, array('width', 'height'), TRUE) && ! ctype_digit((string) $val)) + { + continue; + } $this->$key = $val; } -- cgit v1.2.3-24-g4f1b From b3f6934cb870f2da9c9891968e6f4d98effa741e Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 22 Mar 2016 11:31:58 +0200 Subject: [ci skip] Escape image paths passed as shell arguments to imagemagick --- system/libraries/Image_lib.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'system/libraries/Image_lib.php') diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php index edd13372d..24fe8c68d 100644 --- a/system/libraries/Image_lib.php +++ b/system/libraries/Image_lib.php @@ -866,27 +866,28 @@ class CI_Image_lib { if ($action === 'crop') { - $cmd .= ' -crop '.$this->width.'x'.$this->height.'+'.$this->x_axis.'+'.$this->y_axis.' "'.$this->full_src_path.'" "'.$this->full_dst_path .'" 2>&1'; + $cmd .= ' -crop '.$this->width.'x'.$this->height.'+'.$this->x_axis.'+'.$this->y_axis; } elseif ($action === 'rotate') { - $angle = ($this->rotation_angle === 'hor' OR $this->rotation_angle === 'vrt') - ? '-flop' : '-rotate '.$this->rotation_angle; - - $cmd .= ' '.$angle.' "'.$this->full_src_path.'" "'.$this->full_dst_path.'" 2>&1'; + $cmd .= ($this->rotation_angle === 'hor' OR $this->rotation_angle === 'vrt') + ? ' -flop' + : ' -rotate '.$this->rotation_angle; } else // Resize { if($this->maintain_ratio === TRUE) { - $cmd .= ' -resize '.$this->width.'x'.$this->height.' "'.$this->full_src_path.'" "'.$this->full_dst_path.'" 2>&1'; + $cmd .= ' -resize '.$this->width.'x'.$this->height; } else { - $cmd .= ' -resize '.$this->width.'x'.$this->height.'\! "'.$this->full_src_path.'" "'.$this->full_dst_path.'" 2>&1'; + $cmd .= ' -resize '.$this->width.'x'.$this->height.'\!'; } } + $cmd .= ' "'.escapeshellarg($this->full_src_path).'" "'.escapeshellarg($this->full_dst_path).'" 2>&1'; + $retval = 1; // exec() might be disabled if (function_usable('exec')) -- cgit v1.2.3-24-g4f1b From b9f53a8d7a96bad5c6f1ff7e41a075fcb5d8fb5c Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 29 Jul 2016 11:31:05 +0300 Subject: [ci skip] Fix #4736 --- system/libraries/Image_lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/libraries/Image_lib.php') diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php index 24fe8c68d..7ec8ba365 100644 --- a/system/libraries/Image_lib.php +++ b/system/libraries/Image_lib.php @@ -886,7 +886,7 @@ class CI_Image_lib { } } - $cmd .= ' "'.escapeshellarg($this->full_src_path).'" "'.escapeshellarg($this->full_dst_path).'" 2>&1'; + $cmd .= escapeshellarg($this->full_src_path).' '.escapeshellarg($this->full_dst_path).' 2>&1'; $retval = 1; // exec() might be disabled -- cgit v1.2.3-24-g4f1b From be8bd923329cf233fb3828afab5c3b4ceef296ec Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 7 Nov 2016 12:31:31 +0200 Subject: Fix #4902 --- system/libraries/Image_lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/libraries/Image_lib.php') diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php index 7ec8ba365..06cdde0b8 100644 --- a/system/libraries/Image_lib.php +++ b/system/libraries/Image_lib.php @@ -886,7 +886,7 @@ class CI_Image_lib { } } - $cmd .= escapeshellarg($this->full_src_path).' '.escapeshellarg($this->full_dst_path).' 2>&1'; + $cmd .= ' '.escapeshellarg($this->full_src_path).' '.escapeshellarg($this->full_dst_path).' 2>&1'; $retval = 1; // exec() might be disabled -- cgit v1.2.3-24-g4f1b From 961271dc3d02d7b2f71847983c8e5a03ca003582 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 9 Dec 2016 12:48:57 +0200 Subject: [ci skip] Fix #4937 --- system/libraries/Image_lib.php | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) (limited to 'system/libraries/Image_lib.php') diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php index 06cdde0b8..39a30f0f5 100644 --- a/system/libraries/Image_lib.php +++ b/system/libraries/Image_lib.php @@ -544,35 +544,28 @@ class CI_Image_lib { */ if ($this->new_image === '') { - $this->dest_image = $this->source_image; + $this->dest_image = $this->source_image; $this->dest_folder = $this->source_folder; } - elseif (strpos($this->new_image, '/') === FALSE) + elseif (strpos($this->new_image, '/') === FALSE && strpos($this->new_image, '\\') === FALSE) { + $this->dest_image = $this->new_image; $this->dest_folder = $this->source_folder; - $this->dest_image = $this->new_image; } else { - if (strpos($this->new_image, '/') === FALSE && strpos($this->new_image, '\\') === FALSE) - { - $full_dest_path = str_replace('\\', '/', realpath($this->new_image)); - } - else - { - $full_dest_path = $this->new_image; - } + $full_dest_path = str_replace('\\', '/', realpath($this->new_image)); // Is there a file name? if ( ! preg_match('#\.(jpg|jpeg|gif|png)$#i', $full_dest_path)) { + $this->dest_image = $this->source_image; $this->dest_folder = $full_dest_path.'/'; - $this->dest_image = $this->source_image; } else { $x = explode('/', $full_dest_path); - $this->dest_image = end($x); + $this->dest_image = end($x); $this->dest_folder = str_replace($this->dest_image, '', $full_dest_path); } } -- cgit v1.2.3-24-g4f1b From f2a613d67c23ba253f35a73d208e0dcaf6080b40 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 12 Dec 2016 11:39:38 +0200 Subject: Really fix #4937 --- system/libraries/Image_lib.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'system/libraries/Image_lib.php') diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php index 39a30f0f5..475649c46 100644 --- a/system/libraries/Image_lib.php +++ b/system/libraries/Image_lib.php @@ -554,20 +554,20 @@ class CI_Image_lib { } else { - $full_dest_path = str_replace('\\', '/', realpath($this->new_image)); - // Is there a file name? - if ( ! preg_match('#\.(jpg|jpeg|gif|png)$#i', $full_dest_path)) + if ( ! preg_match('#\.(jpg|jpeg|gif|png)$#i', $this->new_image)) { $this->dest_image = $this->source_image; - $this->dest_folder = $full_dest_path.'/'; + $this->dest_folder = $this->new_image; } else { - $x = explode('/', $full_dest_path); + $x = explode('/', str_replace('\\', '/', $this->new_image)); $this->dest_image = end($x); - $this->dest_folder = str_replace($this->dest_image, '', $full_dest_path); + $this->dest_folder = str_replace($this->dest_image, '', $this->new_image); } + + $this->dest_folder = realpath($this->dest_folder).'/'; } /* Compile the finalized filenames/paths -- cgit v1.2.3-24-g4f1b From 62adbbd6cb2bc56258817efbc8f201250de6b64d Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 16 Dec 2016 15:48:14 +0200 Subject: [ci skip] Remove a function_exists() call from CI_Image_lib We use this function elsewhere without checking for existence; nobody has complained --- system/libraries/Image_lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/libraries/Image_lib.php') diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php index 475649c46..884d0dcec 100644 --- a/system/libraries/Image_lib.php +++ b/system/libraries/Image_lib.php @@ -1194,7 +1194,7 @@ class CI_Image_lib { } // Build the finalized image - if ($wm_img_type === 3 && function_exists('imagealphablending')) + if ($wm_img_type === 3) { @imagealphablending($src_img, TRUE); } -- cgit v1.2.3-24-g4f1b From fced25f5728ce81fe810216fcaa4ccec7523f6c9 Mon Sep 17 00:00:00 2001 From: Master Yoda Date: Sat, 31 Dec 2016 08:46:18 -0800 Subject: Update copyright data to 2017 --- system/libraries/Image_lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'system/libraries/Image_lib.php') diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php index 884d0dcec..0685692de 100644 --- a/system/libraries/Image_lib.php +++ b/system/libraries/Image_lib.php @@ -6,7 +6,7 @@ * * This content is released under the MIT License (MIT) * - * Copyright (c) 2014 - 2016, British Columbia Institute of Technology + * Copyright (c) 2014 - 2017, British Columbia Institute of Technology * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * @package CodeIgniter * @author EllisLab Dev Team * @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/) - * @copyright Copyright (c) 2014 - 2016, British Columbia Institute of Technology (http://bcit.ca/) + * @copyright Copyright (c) 2014 - 2017, British Columbia Institute of Technology (http://bcit.ca/) * @license http://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 1.0.0 -- cgit v1.2.3-24-g4f1b From da60e9bc66ec90970fbd2dfd08b0a6e66b9f5f5f Mon Sep 17 00:00:00 2001 From: Master Yoda Date: Sat, 31 Dec 2016 08:46:18 -0800 Subject: Update copyright data to 2017 --- system/libraries/Image_lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'system/libraries/Image_lib.php') diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php index 475649c46..3e45cb845 100644 --- a/system/libraries/Image_lib.php +++ b/system/libraries/Image_lib.php @@ -6,7 +6,7 @@ * * This content is released under the MIT License (MIT) * - * Copyright (c) 2014 - 2016, British Columbia Institute of Technology + * Copyright (c) 2014 - 2017, British Columbia Institute of Technology * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * @package CodeIgniter * @author EllisLab Dev Team * @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/) - * @copyright Copyright (c) 2014 - 2016, British Columbia Institute of Technology (http://bcit.ca/) + * @copyright Copyright (c) 2014 - 2017, British Columbia Institute of Technology (http://bcit.ca/) * @license http://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 1.0.0 -- cgit v1.2.3-24-g4f1b From 747deff00e0597a1285d416569ef929b14ab8373 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 6 Jan 2017 13:22:16 +0200 Subject: Merge pull request #4457 from KN4CK3R/develop Fix CI_Image_lib::get_image_properties() invalid image handling --- system/libraries/Image_lib.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'system/libraries/Image_lib.php') diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php index 3e45cb845..9eb05c2fd 100644 --- a/system/libraries/Image_lib.php +++ b/system/libraries/Image_lib.php @@ -1639,6 +1639,11 @@ class CI_Image_lib { } $vals = getimagesize($path); + if ($vals === FALSE) + { + $this->set_error('imglib_invalid_image'); + return FALSE; + } $types = array(1 => 'gif', 2 => 'jpeg', 3 => 'png'); $mime = (isset($types[$vals[2]])) ? 'image/'.$types[$vals[2]] : 'image/jpg'; -- cgit v1.2.3-24-g4f1b From 5f7302c7ea5c76fbc3fdcac88aead48deb7adcdb Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 6 Jan 2017 13:26:08 +0200 Subject: [ci skip] Cosmetich changes to CI_Image_lib::get_image_properties() --- system/libraries/Image_lib.php | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'system/libraries/Image_lib.php') diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php index 9eb05c2fd..9ec44da0c 100644 --- a/system/libraries/Image_lib.php +++ b/system/libraries/Image_lib.php @@ -1644,25 +1644,26 @@ class CI_Image_lib { $this->set_error('imglib_invalid_image'); return FALSE; } + $types = array(1 => 'gif', 2 => 'jpeg', 3 => 'png'); - $mime = (isset($types[$vals[2]])) ? 'image/'.$types[$vals[2]] : 'image/jpg'; + $mime = isset($types[$vals[2]]) ? 'image/'.$types[$vals[2]] : 'image/jpg'; if ($return === TRUE) { return array( - 'width' => $vals[0], - 'height' => $vals[1], - 'image_type' => $vals[2], - 'size_str' => $vals[3], - 'mime_type' => $mime - ); - } - - $this->orig_width = $vals[0]; - $this->orig_height = $vals[1]; - $this->image_type = $vals[2]; - $this->size_str = $vals[3]; - $this->mime_type = $mime; + 'width' => $vals[0], + 'height' => $vals[1], + 'image_type' => $vals[2], + 'size_str' => $vals[3], + 'mime_type' => $mime + ); + } + + $this->orig_width = $vals[0]; + $this->orig_height = $vals[1]; + $this->image_type = $vals[2]; + $this->size_str = $vals[3]; + $this->mime_type = $mime; return TRUE; } -- cgit v1.2.3-24-g4f1b From 8f9ab65270ae033c5637f8a7d26ae834e9a71d5e Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 10 Jan 2017 12:30:38 +0200 Subject: [ci skip] CI_Image_lib to set gd.jpeg_ignore_warning = 1 See #4967 --- system/libraries/Image_lib.php | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'system/libraries/Image_lib.php') diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php index 9ec44da0c..88c9e7ede 100644 --- a/system/libraries/Image_lib.php +++ b/system/libraries/Image_lib.php @@ -392,6 +392,16 @@ class CI_Image_lib { $this->initialize($props); } + /** + * A work-around for some improperly formatted, but + * usable JPEGs; known to be produced by Samsung + * smartphones' front-facing cameras. + * + * @see https://github.com/bcit-ci/CodeIgniter/issues/4967 + * @see https://bugs.php.net/bug.php?id=72404 + */ + ini_set('gd.jpeg_ignore_warning', 1); + log_message('info', 'Image Lib Class Initialized'); } -- cgit v1.2.3-24-g4f1b