Verzeichnisstruktur phpBB-3.1.0
- Veröffentlicht
- 27.10.2014
So funktioniert es
|
Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück |
Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
Escaper.php
01 <?php
02
03 /*
04 * This file is part of the Symfony package.
05 *
06 * (c) Fabien Potencier <fabien@symfony.com>
07 *
08 * For the full copyright and license information, please view the LICENSE
09 * file that was distributed with this source code.
10 */
11
12 namespace Symfony\Component\Yaml;
13
14 /**
15 * Escaper encapsulates escaping rules for single and double-quoted
16 * YAML strings.
17 *
18 * @author Matthew Lewinski <matthew@lewinski.org>
19 */
20 class Escaper
21 {
22 // Characters that would cause a dumped string to require double quoting.
23 const REGEX_CHARACTER_TO_ESCAPE = "[\\x00-\\x1f]|\xc2\x85|\xc2\xa0|\xe2\x80\xa8|\xe2\x80\xa9";
24
25 // Mapping arrays for escaping a double quoted string. The backslash is
26 // first to ensure proper escaping because str_replace operates iteratively
27 // on the input arrays. This ordering of the characters avoids the use of strtr,
28 // which performs more slowly.
29 private static $escapees = array('\\', '\\\\', '\\"', '"',
30 "\x00", "\x01", "\x02", "\x03", "\x04", "\x05", "\x06", "\x07",
31 "\x08", "\x09", "\x0a", "\x0b", "\x0c", "\x0d", "\x0e", "\x0f",
32 "\x10", "\x11", "\x12", "\x13", "\x14", "\x15", "\x16", "\x17",
33 "\x18", "\x19", "\x1a", "\x1b", "\x1c", "\x1d", "\x1e", "\x1f",
34 "\xc2\x85", "\xc2\xa0", "\xe2\x80\xa8", "\xe2\x80\xa9",);
35 private static $escaped = array('\\\\', '\\"', '\\\\', '\\"',
36 "\\0", "\\x01", "\\x02", "\\x03", "\\x04", "\\x05", "\\x06", "\\a",
37 "\\b", "\\t", "\\n", "\\v", "\\f", "\\r", "\\x0e", "\\x0f",
38 "\\x10", "\\x11", "\\x12", "\\x13", "\\x14", "\\x15", "\\x16", "\\x17",
39 "\\x18", "\\x19", "\\x1a", "\\e", "\\x1c", "\\x1d", "\\x1e", "\\x1f",
40 "\\N", "\\_", "\\L", "\\P",);
41
42 /**
43 * Determines if a PHP value would require double quoting in YAML.
44 *
45 * @param string $value A PHP value
46 *
47 * @return bool True if the value would require double quotes.
48 */
49 public static function requiresDoubleQuoting($value)
50 {
51 return preg_match('/'.self::REGEX_CHARACTER_TO_ESCAPE.'/u', $value);
52 }
53
54 /**
55 * Escapes and surrounds a PHP value with double quotes.
56 *
57 * @param string $value A PHP value
58 *
59 * @return string The quoted, escaped string
60 */
61 public static function escapeWithDoubleQuotes($value)
62 {
63 return sprintf('"%s"', str_replace(self::$escapees, self::$escaped, $value));
64 }
65
66 /**
67 * Determines if a PHP value would require single quoting in YAML.
68 *
69 * @param string $value A PHP value
70 *
71 * @return bool True if the value would require single quotes.
72 */
73 public static function requiresSingleQuoting($value)
74 {
75 return preg_match('/[ \s \' " \: \{ \} \[ \] , & \* \# \?] | \A[ \- ? | < > = ! % @ ` ]/x', $value);
76 }
77
78 /**
79 * Escapes and surrounds a PHP value with single quotes.
80 *
81 * @param string $value A PHP value
82 *
83 * @return string The quoted, escaped string
84 */
85 public static function escapeWithSingleQuotes($value)
86 {
87 return sprintf("'%s'", str_replace('\'', '\'\'', $value));
88 }
89 }
90