/usr/share/php/Horde/Url/Data.php is in php-horde-url 2.2.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | <?php
/**
* Copyright 2013 Horde LLC (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (LGPL). If you
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
*
* @category Horde
* @copyright 2013 Horde LLC
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @package Url
*/
/**
* An object to handle Data URLs (RFC 2397).
*
* @author Michael Slusarz <slusarz@horde.org>
* @category Horde
* @copyright 2013 Horde LLC
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @package Url
*/
class Horde_Url_Data
{
/**
* Should data be base64 encoded?
*
* @var boolean
*/
public $base64 = true;
/**
* Binary data.
*
* @var string
*/
public $data = '';
/**
* The MIME type.
*
* @var string
*/
public $type = 'application/octet-stream';
/**
* Create a new object from existing data.
*
* @param string $type The MIME type of the data.
* @param string $data The data.
* @param boolean $base64 Should data be base64 encoded?
*/
static public function create($type = null, $data = null, $base64 = true)
{
$ob = new self();
if (!is_null($type)) {
$ob->type = $type;
}
if (!is_null($data)) {
$ob->data = $data;
}
$ob->base64 = (bool)$base64;
return $ob;
}
/**
* Check input to see if it contains RFC 2397 data.
*
* @since 2.2.0
*
* @param mixed $data Input.
*
* @return boolean True if the input contains RFC 2397 compliant data.
*/
static public function isData($input)
{
if (is_object($input)) {
return ($input instanceof self);
}
return (is_string($input) && (strpos($input, 'data:') === 0));
}
/**
* Constructor.
*
* @param string $data An RFC 2397 compliant data string.
*/
public function __construct($data = null)
{
if (!is_null($data) && self::isData($data)) {
$fp = fopen(strval($data), 'r');
$this->data = stream_get_contents($fp);
$meta = stream_get_meta_data($fp);
$this->type = $meta['mediatype'];
}
}
/**
* Output RFC 2397 compliant data string.
*/
public function __toString()
{
return 'data:' . htmlspecialchars($this->type) .
($this->base64
? ';base64,' . base64_encode($this->data)
: ',' . rawurlencode($this->data));
}
}
|