Skip to content

Commit

Permalink
Fix Encoded Data Image URL Bug
Browse files Browse the repository at this point in the history
Fix encoded data image URL being passed to the `imagecreatefromstring()` without decoding it first.
  • Loading branch information
taufik-nurrohman committed May 16, 2020
1 parent 7e31094 commit c8a59d9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ Image Extension for Mecha
Release Notes
-------------

### 2.2.4

- Fix encoded data image URL being passed to the `imagecreatefromstring()` without decoding it first.

### 2.2.3

- API has been reduced to only have an ability to resize and crop images. Other abilities such as flipping and rotating an image can be enabled in a separate extension. This extension is now focused to help authors in generating image thumbnails.
Expand Down
2 changes: 1 addition & 1 deletion image/about.page
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: Image
description: Image resizer and cropper.
author: Taufik Nurrohman
type: Markdown
version: 2.2.3
version: 2.2.4

use:
'.\lot\x\page': 0
Expand Down
2 changes: 1 addition & 1 deletion image/engine/kernel/g-d.image.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function __construct(string $path = null) {
if (\is_string($path)) {
// Create image from string
if (0 === \strpos($path, 'data:image/') && false !== \strpos($path, ';base64,')) {
$blob = \imagecreatefromstring(\base64_decode(\explode(',', $path, 2)[1]));
$blob = \imagecreatefromstring(\base64_decode(\explode(',', $path = \urldecode($path), 2)[1]));
$type = \substr(\explode(';', $path, 2)[0], 5);
// Create image from remote URL
} else if (false !== \strpos($path, '://') || 0 === \strpos($path, '/') && 0 !== \strpos($path, \ROOT)) {
Expand Down

0 comments on commit c8a59d9

Please sign in to comment.