Implements data: URI for base64 encoded images supported by GD.
More...
Implements data: URI for base64 encoded images supported by GD.
Definition at line 6 of file data.php.
◆ doValidate()
HTMLPurifier_URIScheme_data::doValidate |
( |
& |
$uri, |
|
|
|
$config, |
|
|
|
$context |
|
) |
| |
- Parameters
-
- Returns
- bool
Definition at line 36 of file data.php.
References $data, $file, $info, $result, and array.
38 $result = explode(
',', $uri->path, 2);
45 $metas = explode(
';', $metadata);
46 while (!empty($metas)) {
47 $cur = array_shift($metas);
48 if ($cur ==
'base64') {
52 if (substr($cur, 0, 8) ==
'charset=') {
55 if ($charset !== null) {
58 $charset = substr($cur, 8);
60 if ($content_type !== null) {
69 if ($content_type !== null && empty($this->allowed_types[$content_type])) {
72 if ($charset !== null) {
78 $raw_data = base64_decode(
$data);
82 if ( strlen($raw_data) < 12 ) {
89 if (function_exists(
'sys_get_temp_dir')) {
90 $file = tempnam(sys_get_temp_dir(),
"");
92 $file = tempnam(
"/tmp",
"");
94 file_put_contents(
$file, $raw_data);
95 if (function_exists(
'exif_imagetype')) {
96 $image_code = exif_imagetype(
$file);
98 } elseif (function_exists(
'getimagesize')) {
99 set_error_handler(
array($this,
'muteErrorHandler'));
101 restore_error_handler();
103 if (
$info ==
false) {
106 $image_code =
$info[2];
108 trigger_error(
"could not find exif_imagetype or getimagesize functions", E_USER_ERROR);
110 $real_content_type = image_type_to_mime_type($image_code);
111 if ($real_content_type != $content_type) {
114 if (empty($this->allowed_types[$real_content_type])) {
117 $content_type = $real_content_type;
120 $uri->userinfo = null;
123 $uri->fragment = null;
125 $uri->path =
"$content_type;base64," . base64_encode($raw_data);
Create styles array
The data for the language used.
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
◆ muteErrorHandler()
HTMLPurifier_URIScheme_data::muteErrorHandler |
( |
|
$errno, |
|
|
|
$errstr |
|
) |
| |
◆ $allowed_types
HTMLPurifier_URIScheme_data::$allowed_types |
Initial value:
'image/jpeg' => true,
'image/gif' => true,
'image/png' => true,
)
array
Definition at line 16 of file data.php.
◆ $browsable
HTMLPurifier_URIScheme_data::$browsable = true |
◆ $may_omit_host
HTMLPurifier_URIScheme_data::$may_omit_host = true |
The documentation for this class was generated from the following file:
- libs/composer/vendor/ezyang/htmlpurifier/library/HTMLPurifier/URIScheme/data.php