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. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
RegexpFilter.php
01 <?php
02
03 /*
04 * @package s9e\TextFormatter
05 * @copyright Copyright (c) 2010-2016 The s9e Authors
06 * @license http://www.opensource.org/licenses/mit-license.php The MIT License
07 */
08 namespace s9e\TextFormatter\Configurator\Items\AttributeFilters;
09 use Exception;
10 use RuntimeException;
11 use s9e\TextFormatter\Configurator\Helpers\ContextSafeness;
12 use s9e\TextFormatter\Configurator\Helpers\RegexpParser;
13 use s9e\TextFormatter\Configurator\Items\AttributeFilter;
14 use s9e\TextFormatter\Configurator\Items\Regexp;
15 class RegexpFilter extends AttributeFilter
16 {
17 public function __construct($regexp = \null)
18 {
19 parent::__construct('s9e\\TextFormatter\\Parser\\BuiltInFilters::filterRegexp');
20 $this->resetParameters();
21 $this->addParameterByName('attrValue');
22 $this->addParameterByName('regexp');
23 $this->setJS('BuiltInFilters.filterRegexp');
24 if (isset($regexp))
25 $this->setRegexp($regexp);
26 }
27 public function asConfig()
28 {
29 if (!isset($this->vars['regexp']))
30 throw new RuntimeException("Regexp filter is missing a 'regexp' value");
31 return parent::asConfig();
32 }
33 public function getRegexp()
34 {
35 return (string) $this->vars['regexp'];
36 }
37 public function setRegexp($regexp)
38 {
39 if (\is_string($regexp))
40 $regexp = new Regexp($regexp);
41 $this->vars['regexp'] = $regexp;
42 $this->resetSafeness();
43 $this->evaluateSafeness();
44 }
45 protected function evaluateSafeness()
46 {
47 try
48 {
49 $this->evaluateSafenessAsURL();
50 $this->evaluateSafenessInCSS();
51 $this->evaluateSafenessInJS();
52 }
53 catch (Exception $e)
54 {
55 }
56 }
57 protected function evaluateSafenessAsURL()
58 {
59 $regexpInfo = RegexpParser::parse($this->vars['regexp']);
60 $captureStart = '(?>\\((?:\\?:)?)*';
61 $regexp = '#^\\^' . $captureStart . '(?!data|\\w*script)[a-z0-9]+\\??:#i';
62 if (\preg_match($regexp, $regexpInfo['regexp'])
63 && \strpos($regexpInfo['modifiers'], 'm') === \false)
64 {
65 $this->markAsSafeAsURL();
66 return;
67 }
68 $regexp = RegexpParser::getAllowedCharacterRegexp($this->vars['regexp']);
69 foreach (ContextSafeness::getDisallowedCharactersAsURL() as $char)
70 if (\preg_match($regexp, $char))
71 return;
72 $this->markAsSafeAsURL();
73 }
74 protected function evaluateSafenessInCSS()
75 {
76 $regexp = RegexpParser::getAllowedCharacterRegexp($this->vars['regexp']);
77 foreach (ContextSafeness::getDisallowedCharactersInCSS() as $char)
78 if (\preg_match($regexp, $char))
79 return;
80 $this->markAsSafeInCSS();
81 }
82 protected function evaluateSafenessInJS()
83 {
84 $safeExpressions = array(
85 '\\d+',
86 '[0-9]+'
87 );
88 $regexp = '(^(?<delim>.)\\^(?:(?<expr>' . \implode('|', \array_map('preg_quote', $safeExpressions)) . ')|\\((?:\\?[:>])?(?&expr)\\))\\$(?&delim)(?=.*D)[Dis]*$)D';
89 if (\preg_match($regexp, $this->vars['regexp']))
90 $this->markAsSafeInJS();
91 }
92 }