Verzeichnisstruktur phpBB-3.2.0


Veröffentlicht
06.01.2017

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:54 - Dateigröße: 4.32 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   * @internal
 021   */
 022  class Unescaper
 023  {
 024      /**
 025       * Parser and Inline assume UTF-8 encoding, so escaped Unicode characters
 026       * must be converted to that encoding.
 027       *
 028       * @deprecated since version 2.5, to be removed in 3.0
 029       *
 030       * @internal
 031       */
 032      const ENCODING = 'UTF-8';
 033   
 034      /**
 035       * Regex fragment that matches an escaped character in a double quoted string.
 036       */
 037      const REGEX_ESCAPED_CHARACTER = '\\\\(x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|U[0-9a-fA-F]{8}|.)';
 038   
 039      /**
 040       * Unescapes a single quoted string.
 041       *
 042       * @param string $value A single quoted string
 043       *
 044       * @return string The unescaped string
 045       */
 046      public function unescapeSingleQuotedString($value)
 047      {
 048          return str_replace('\'\'', '\'', $value);
 049      }
 050   
 051      /**
 052       * Unescapes a double quoted string.
 053       *
 054       * @param string $value A double quoted string
 055       *
 056       * @return string The unescaped string
 057       */
 058      public function unescapeDoubleQuotedString($value)
 059      {
 060          $self = $this;
 061          $callback = function ($match) use ($self) {
 062              return $self->unescapeCharacter($match[0]);
 063          };
 064   
 065          // evaluate the string
 066          return preg_replace_callback('/'.self::REGEX_ESCAPED_CHARACTER.'/u', $callback, $value);
 067      }
 068   
 069      /**
 070       * Unescapes a character that was found in a double-quoted string.
 071       *
 072       * @param string $value An escaped character
 073       *
 074       * @return string The unescaped character
 075       *
 076       * @internal This method is public to be usable as callback. It should not
 077       *           be used in user code. Should be changed in 3.0.
 078       */
 079      public function unescapeCharacter($value)
 080      {
 081          switch ($value[1]) {
 082              case '0':
 083                  return "\x0";
 084              case 'a':
 085                  return "\x7";
 086              case 'b':
 087                  return "\x8";
 088              case 't':
 089                  return "\t";
 090              case "\t":
 091                  return "\t";
 092              case 'n':
 093                  return "\n";
 094              case 'v':
 095                  return "\xB";
 096              case 'f':
 097                  return "\xC";
 098              case 'r':
 099                  return "\r";
 100              case 'e':
 101                  return "\x1B";
 102              case ' ':
 103                  return ' ';
 104              case '"':
 105                  return '"';
 106              case '/':
 107                  return '/';
 108              case '\\':
 109                  return '\\';
 110              case 'N':
 111                  // U+0085 NEXT LINE
 112                  return "\xC2\x85";
 113              case '_':
 114                  // U+00A0 NO-BREAK SPACE
 115                  return "\xC2\xA0";
 116              case 'L':
 117                  // U+2028 LINE SEPARATOR
 118                  return "\xE2\x80\xA8";
 119              case 'P':
 120                  // U+2029 PARAGRAPH SEPARATOR
 121                  return "\xE2\x80\xA9";
 122              case 'x':
 123                  return self::utf8chr(hexdec(substr($value, 2, 2)));
 124              case 'u':
 125                  return self::utf8chr(hexdec(substr($value, 2, 4)));
 126              case 'U':
 127                  return self::utf8chr(hexdec(substr($value, 2, 8)));
 128              default:
 129                  @trigger_error('Not escaping a backslash in a double-quoted string is deprecated since Symfony 2.8 and will throw a ParseException in 3.0.', E_USER_DEPRECATED);
 130   
 131                  return $value;
 132          }
 133      }
 134   
 135      /**
 136       * Get the UTF-8 character for the given code point.
 137       *
 138       * @param int $c The unicode code point
 139       *
 140       * @return string The corresponding UTF-8 character
 141       */
 142      private static function utf8chr($c)
 143      {
 144          if (0x80 > $c %= 0x200000) {
 145              return chr($c);
 146          }
 147          if (0x800 > $c) {
 148              return chr(0xC0 | $c >> 6).chr(0x80 | $c & 0x3F);
 149          }
 150          if (0x10000 > $c) {
 151              return chr(0xE0 | $c >> 12).chr(0x80 | $c >> 6 & 0x3F).chr(0x80 | $c & 0x3F);
 152          }
 153   
 154          return chr(0xF0 | $c >> 18).chr(0x80 | $c >> 12 & 0x3F).chr(0x80 | $c >> 6 & 0x3F).chr(0x80 | $c & 0x3F);
 155      }
 156  }
 157