|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the eluceo/iCal package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Markus Poerschke <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* This source file is subject to the MIT license that is bundled |
|
9
|
|
|
* with this source code in the file LICENSE. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace Eluceo\iCal\Util; |
|
13
|
|
|
|
|
14
|
|
|
class PropertyValueUtil |
|
15
|
|
|
{ |
|
16
|
17 |
|
public static function escapeValue($value) |
|
17
|
|
|
{ |
|
18
|
17 |
|
$value = self::escapeValueAllowNewLine($value); |
|
19
|
17 |
|
$value = str_replace("\n", '\\n', $value); |
|
20
|
|
|
|
|
21
|
17 |
|
return $value; |
|
22
|
|
|
} |
|
23
|
|
|
|
|
24
|
17 |
|
public static function escapeValueAllowNewLine($value) |
|
25
|
|
|
{ |
|
26
|
17 |
|
$value = str_replace('\\', '\\\\', $value); |
|
27
|
17 |
|
$value = str_replace('"', '\\"', $value); |
|
28
|
17 |
|
$value = str_replace(',', '\\,', $value); |
|
29
|
17 |
|
$value = str_replace(';', '\\;', $value); |
|
30
|
17 |
|
$value = str_replace(array( |
|
31
|
17 |
|
"\x00", "\x01", "\x02", "\x03", "\x04", "\x05", "\x06", "\x07", |
|
32
|
17 |
|
"\x08", "\x09", /* \n*/ "\x0B", "\x0C", "\x0D", "\x0E", "\x0F", |
|
33
|
17 |
|
"\x10", "\x11", "\x12", "\x13", "\x14", "\x15", "\x16", "\x17", |
|
34
|
17 |
|
"\x18", "\x19", "\x1A", "\x1B", "\x1C", "\x1D", "\x1E", "\x1F", |
|
35
|
17 |
|
"\x7F", |
|
36
|
17 |
|
), '', $value); |
|
37
|
|
|
|
|
38
|
17 |
|
return $value; |
|
39
|
|
|
} |
|
40
|
|
|
} |
|
41
|
|
|
|