mirror of
https://github.com/Intervention/image.git
synced 2025-02-06 13:59:12 +01:00
Merge branch 'kalatabe-handle_whitespaced_b64'
This commit is contained in:
commit
3716991ae9
@ -262,7 +262,7 @@ abstract class AbstractDecoder
|
||||
return false;
|
||||
}
|
||||
|
||||
return base64_encode(base64_decode($this->data)) === $this->data;
|
||||
return base64_encode(base64_decode($this->data)) === str_replace(["\n", "\r"], '', $this->data);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -144,6 +144,13 @@ class AbstractDecoderTest extends TestCase
|
||||
$base64 = "iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAGElEQVQYlWM8c+bMfwYiABMxikYVUk8hAHWzA3cRvs4UAAAAAElFTkSuQmCC";
|
||||
$decoder = $this->getTestDecoder($base64);
|
||||
$this->assertTrue($decoder->isBase64());
|
||||
|
||||
$base64WithNewlines = 'iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+' . "\n" .
|
||||
'9AAAAGElEQVQYlWM8c+bMfwYiABMxikYVUk8hAHWzA3' . "\n" .
|
||||
'cRvs4UAAAAAElFTkSuQmCC';
|
||||
|
||||
$decoder = $this->getTestDecoder($base64WithNewlines);
|
||||
$this->assertTrue($decoder->isBase64());
|
||||
}
|
||||
|
||||
public function getTestDecoder($data)
|
||||
|
@ -25,10 +25,10 @@ class GdSystemTest extends TestCase
|
||||
/**
|
||||
* @expectedException \Intervention\Image\Exception\NotReadableException
|
||||
*/
|
||||
public function testMakeFromPathBroken()
|
||||
{
|
||||
$this->manager()->make('tests/images/broken.png');
|
||||
}
|
||||
public function testMakeFromPathBroken()
|
||||
{
|
||||
$this->manager()->make('tests/images/broken.png');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Intervention\Image\Exception\NotReadableException
|
||||
@ -85,6 +85,22 @@ class GdSystemTest extends TestCase
|
||||
$this->assertEquals(10, $img->getHeight());
|
||||
}
|
||||
|
||||
public function testMakeFromBase64WithNewlines()
|
||||
{
|
||||
$data = 'iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+' . "\n" .
|
||||
'9AAAAGElEQVQYlWM8c+bMfwYiABMxikYVUk8hAHWzA3' . "\n" .
|
||||
'cRvs4UAAAAAElFTkSuQmCC';
|
||||
|
||||
$img = $this->manager()->make($data);
|
||||
|
||||
$this->assertInstanceOf('Intervention\Image\Image', $img);
|
||||
$this->assertInternalType('resource', $img->getCore());
|
||||
$this->assertInternalType('int', $img->getWidth());
|
||||
$this->assertInternalType('int', $img->getHeight());
|
||||
$this->assertEquals(10, $img->getWidth());
|
||||
$this->assertEquals(10, $img->getHeight());
|
||||
}
|
||||
|
||||
public function testMakeFromWebp()
|
||||
{
|
||||
if (function_exists('imagecreatefromwebp')) {
|
||||
|
@ -73,6 +73,23 @@ class ImagickSystemTest extends TestCase
|
||||
$this->assertEquals('image/png', $img->mime);
|
||||
}
|
||||
|
||||
public function testMakeFromBase64WithNewlines()
|
||||
{
|
||||
$data = 'iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+' . "\n" .
|
||||
'9AAAAGElEQVQYlWM8c+bMfwYiABMxikYVUk8hAHWzA3' . "\n" .
|
||||
'cRvs4UAAAAAElFTkSuQmCC';
|
||||
|
||||
$img = $this->manager()->make($data);
|
||||
$this->assertInstanceOf('Intervention\Image\Image', $img);
|
||||
$this->assertInstanceOf('Imagick', $img->getCore());
|
||||
$this->assertInternalType('int', $img->getWidth());
|
||||
$this->assertInternalType('int', $img->getHeight());
|
||||
$this->assertEquals(10, $img->getWidth());
|
||||
$this->assertEquals(10, $img->getHeight());
|
||||
$this->assertEquals('image/png', $img->mime);
|
||||
}
|
||||
|
||||
|
||||
public function testCanvas()
|
||||
{
|
||||
$img = $this->manager()->canvas(30, 20);
|
||||
|
Loading…
x
Reference in New Issue
Block a user