xref: /PHP-8.0/ext/standard/tests/image/bug70096.phpt (revision cdabbd95)
1--TEST--
2Bug #70096 (Repeated iptcembed() adds superfluous FF bytes)
3--SKIPIF--
4<?php
5if (!extension_loaded('gd')) die('skip gd extension not available');
6if (!function_exists('imagejpeg')) die('skip imagejpeg not available');
7?>
8--FILE--
9<?php
10$filename = __DIR__ . '/bug70096.jpg';
11$im = imagecreatetruecolor(10, 10);
12imagejpeg($im, $filename);
13imagedestroy($im);
14$data = "\x1C\x02x\x00\x0ATest image"
15    . "\x1C\x02t\x00\x22Copyright 2008-2009, The PHP Group";
16$content1 = iptcembed($data, $filename);
17$fp = fopen($filename, "wb");
18fwrite($fp, $content1);
19fclose($fp);
20$content2 = iptcembed($data, $filename);
21$fp = fopen($filename, "wb");
22fwrite($fp, $content2);
23fclose($fp);
24var_dump($content1 === $content2);
25?>
26--CLEAN--
27<?php
28$filename = __DIR__ . '/bug70096.jpg';
29@unlink($filename);
30?>
31--EXPECT--
32bool(true)
33