2
/***********************************************
3
* File : replacenullcharfilter.php
5
* Descr : Filters null characters out of a stream.
9
* Copyright 2015 Zarafa Deutschland GmbH
11
* This program is free software: you can redistribute it and/or modify
12
* it under the terms of the GNU Affero General Public License, version 3,
13
* as published by the Free Software Foundation with the following additional
14
* term according to sec. 7:
16
* According to sec. 7 of the GNU Affero General Public License, version 3,
17
* the terms of the AGPL are supplemented with the following terms:
19
* "Zarafa" is a registered trademark of Zarafa B.V.
20
* "Z-Push" is a registered trademark of Zarafa Deutschland GmbH
21
* The licensing of the Program under the AGPL does not imply a trademark license.
22
* Therefore any rights, title and interest in our trademarks remain entirely with us.
24
* However, if you propagate an unmodified version of the Program you are
25
* allowed to use the term "Z-Push" to indicate that you distribute the Program.
26
* Furthermore you may use our trademarks where it is necessary to indicate
27
* the intended purpose of a product or service provided you use it in accordance
28
* with honest practices in industrial or commercial matters.
29
* If you want to propagate modified versions of the Program under the name "Z-Push",
30
* you may only do so if you have a written permission by Zarafa Deutschland GmbH
31
* (to acquire a permission please contact Zarafa at trademark@zarafa.com).
33
* This program is distributed in the hope that it will be useful,
34
* but WITHOUT ANY WARRANTY; without even the implied warranty of
35
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
36
* GNU Affero General Public License for more details.
38
* You should have received a copy of the GNU Affero General Public License
39
* along with this program. If not, see <http://www.gnu.org/licenses/>.
41
* Consult LICENSE file for details
42
************************************************/
44
class replace_nullchar_filter extends php_user_filter {
47
* This method is called whenever data is read from or written to the attached stream.
49
* @see php_user_filter::filter()
52
* @param resource $out
53
* @param int $consumed
54
* @param boolean $closing
60
function filter($in, $out, &$consumed, $closing) {
61
while ($bucket = stream_bucket_make_writeable($in)) {
62
$bucket->data = str_replace("\0", "", $bucket->data);
63
$consumed += $bucket->datalen;
64
stream_bucket_append($out, $bucket);
70
stream_filter_register('replacenullchar', 'replace_nullchar_filter');
b'\\ No newline at end of file'