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.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

(Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

Unescaper.php

Zuletzt modifiziert: 09.10.2024, 12:58 - Dateigröße: 3.90 KiB


001  <?php
002   
003  /*
004   * This file is part of the Symfony package.
005   *
006   * (c) Fabien Potencier <fabien@symfony.com>
007   *
008   * For the full copyright and license information, please view the LICENSE
009   * file that was distributed with this source code.
010   */
011   
012  namespace Symfony\Component\Yaml;
013   
014  /**
015   * Unescaper encapsulates unescaping rules for single and double-quoted
016   * YAML strings.
017   *
018   * @author Matthew Lewinski <matthew@lewinski.org>
019   */
020  class Unescaper
021  {
022      // Parser and Inline assume UTF-8 encoding, so escaped Unicode characters
023      // must be converted to that encoding.
024      // @deprecated since 2.5, to be removed in 3.0
025      const ENCODING = 'UTF-8';
026   
027      // Regex fragment that matches an escaped character in a double quoted
028      // string.
029      const REGEX_ESCAPED_CHARACTER = "\\\\([0abt\tnvfre \\\"\\/\\\\N_LP]|x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|U[0-9a-fA-F]{8})";
030   
031      /**
032       * Unescapes a single quoted string.
033       *
034       * @param string $value A single quoted string.
035       *
036       * @return string The unescaped string.
037       */
038      public function unescapeSingleQuotedString($value)
039      {
040          return str_replace('\'\'', '\'', $value);
041      }
042   
043      /**
044       * Unescapes a double quoted string.
045       *
046       * @param string $value A double quoted string.
047       *
048       * @return string The unescaped string.
049       */
050      public function unescapeDoubleQuotedString($value)
051      {
052          $self = $this;
053          $callback = function ($match) use ($self) {
054              return $self->unescapeCharacter($match[0]);
055          };
056   
057          // evaluate the string
058          return preg_replace_callback('/'.self::REGEX_ESCAPED_CHARACTER.'/u', $callback, $value);
059      }
060   
061      /**
062       * Unescapes a character that was found in a double-quoted string
063       *
064       * @param string $value An escaped character
065       *
066       * @return string The unescaped character
067       */
068      public function unescapeCharacter($value)
069      {
070          switch ($value{1}) {
071              case '0':
072                  return "\x0";
073              case 'a':
074                  return "\x7";
075              case 'b':
076                  return "\x8";
077              case 't':
078                  return "\t";
079              case "\t":
080                  return "\t";
081              case 'n':
082                  return "\n";
083              case 'v':
084                  return "\xB";
085              case 'f':
086                  return "\xC";
087              case 'r':
088                  return "\r";
089              case 'e':
090                  return "\x1B";
091              case ' ':
092                  return ' ';
093              case '"':
094                  return '"';
095              case '/':
096                  return '/';
097              case '\\':
098                  return '\\';
099              case 'N':
100                  // U+0085 NEXT LINE
101                  return "\xC2\x85";
102              case '_':
103                  // U+00A0 NO-BREAK SPACE
104                  return "\xC2\xA0";
105              case 'L':
106                  // U+2028 LINE SEPARATOR
107                  return "\xE2\x80\xA8";
108              case 'P':
109                  // U+2029 PARAGRAPH SEPARATOR
110                  return "\xE2\x80\xA9";
111              case 'x':
112                  return self::utf8chr(hexdec(substr($value, 2, 2)));
113              case 'u':
114                  return self::utf8chr(hexdec(substr($value, 2, 4)));
115              case 'U':
116                  return self::utf8chr(hexdec(substr($value, 2, 8)));
117          }
118      }
119   
120      /**
121       * Get the UTF-8 character for the given code point.
122       *
123       * @param int $c The unicode code point
124       *
125       * @return string The corresponding UTF-8 character
126       */
127      private static function utf8chr($c)
128      {
129          if (0x80 > $c %= 0x200000) {
130              return chr($c);
131          }
132          if (0x800 > $c) {
133              return chr(0xC0 | $c >> 6).chr(0x80 | $c & 0x3F);
134          }
135          if (0x10000 > $c) {
136              return chr(0xE0 | $c >> 12).chr(0x80 | $c >> 6 & 0x3F).chr(0x80 | $c & 0x3F);
137          }
138   
139          return chr(0xF0 | $c >> 18).chr(0x80 | $c >> 12 & 0x3F).chr(0x80 | $c >> 6 & 0x3F).chr(0x80 | $c & 0x3F);
140      }
141  }
142