Cache
1 day ago
DBPermissions.php
1 day ago
DataEncoder.php
1 day ago
DatabaseOptions.php
1 day ago
Env.php
1 day ago
Escape.php
1 day ago
Glob.php
1 day ago
Hooks.php
1 day ago
Math.php
1 day ago
PluginInfo.php
1 day ago
Sanitize.php
1 day ago
ServerVars.php
1 day ago
SlashMode.php
1 day ago
Strings.php
1 day ago
Times.php
1 day ago
Urls.php
1 day ago
Version.php
1 day ago
WpDefaultDirectories.php
1 day ago
Escape.php
142 lines
| 1 | <?php |
| 2 | |
| 3 | namespace WPStaging\Framework\Utils; |
| 4 | |
| 5 | class Escape |
| 6 | { |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | public function escapeHtml(string $content): string |
| 14 | { |
| 15 | return wp_kses($content, $this->htmlAllowedDuringEscape([])); |
| 16 | } |
| 17 | |
| 18 | |
| 19 | |
| 20 | |
| 21 | |
| 22 | |
| 23 | |
| 24 | public function decodeKsesPost(string $text): string |
| 25 | { |
| 26 | return wp_kses_post(html_entity_decode($text)); |
| 27 | } |
| 28 | |
| 29 | |
| 30 | |
| 31 | |
| 32 | |
| 33 | public function htmlAllowedDuringEscape(array $array): array |
| 34 | { |
| 35 | return [ |
| 36 | 'a' => [ |
| 37 | 'id' => [], |
| 38 | 'href' => [], |
| 39 | 'title' => [], |
| 40 | 'target' => [], |
| 41 | 'rel' => [], |
| 42 | 'class' => [], |
| 43 | ], |
| 44 | 'span' => [ |
| 45 | 'class' => [], |
| 46 | 'title' => [], |
| 47 | ], |
| 48 | 'p' => [], |
| 49 | 'br' => [], |
| 50 | 'b' => [], |
| 51 | 'code' => [], |
| 52 | 'em' => [], |
| 53 | 'strong' => [ |
| 54 | 'class' => [], |
| 55 | ], |
| 56 | 'svg' => [ |
| 57 | 'xmlns' => [], |
| 58 | 'width' => [], |
| 59 | 'height' => [], |
| 60 | 'viewbox' => [], |
| 61 | 'fill' => [], |
| 62 | 'stroke' => [], |
| 63 | 'stroke-width' => [], |
| 64 | 'stroke-linecap' => [], |
| 65 | 'stroke-linejoin' => [], |
| 66 | 'aria-hidden' => [], |
| 67 | 'focusable' => [], |
| 68 | 'role' => [], |
| 69 | 'class' => [], |
| 70 | ], |
| 71 | 'path' => [ |
| 72 | 'd' => [], |
| 73 | 'fill' => [], |
| 74 | 'stroke' => [], |
| 75 | 'stroke-width' => [], |
| 76 | 'stroke-linecap' => [], |
| 77 | 'stroke-linejoin' => [], |
| 78 | ], |
| 79 | 'g' => [ |
| 80 | 'fill' => [], |
| 81 | ], |
| 82 | 'polyline' => [ |
| 83 | 'points' => [], |
| 84 | 'fill' => [], |
| 85 | 'stroke' => [], |
| 86 | ], |
| 87 | 'circle' => [ |
| 88 | 'cx' => [], |
| 89 | 'cy' => [], |
| 90 | 'r' => [], |
| 91 | 'fill' => [], |
| 92 | 'stroke' => [], |
| 93 | ], |
| 94 | 'rect' => [ |
| 95 | 'x' => [], |
| 96 | 'y' => [], |
| 97 | 'width' => [], |
| 98 | 'height' => [], |
| 99 | 'fill' => [], |
| 100 | 'stroke' => [], |
| 101 | ], |
| 102 | 'line' => [ |
| 103 | 'x1' => [], |
| 104 | 'y1' => [], |
| 105 | 'x2' => [], |
| 106 | 'y2' => [], |
| 107 | 'fill' => [], |
| 108 | 'stroke' => [], |
| 109 | ], |
| 110 | 'defs' => [ |
| 111 | 'clipPath' => [], |
| 112 | ], |
| 113 | 'ellipse' => [ |
| 114 | 'cx' => [], |
| 115 | 'cy' => [], |
| 116 | 'rx' => [], |
| 117 | 'ry' => [], |
| 118 | ], |
| 119 | ]; |
| 120 | } |
| 121 | |
| 122 | |
| 123 | |
| 124 | |
| 125 | |
| 126 | |
| 127 | |
| 128 | |
| 129 | public function mysqlRealEscapeString($input) |
| 130 | { |
| 131 | if (is_array($input)) { |
| 132 | return array_map(__METHOD__, $input); |
| 133 | } |
| 134 | |
| 135 | if (!empty($input) && is_string($input)) { |
| 136 | return str_replace(['\\', "\0", "\n", "\r", "'", '"', "\x1a"], ['\\\\', '\\0', '\\n', '\\r', "\\'", '\\"', '\\Z'], $input); |
| 137 | } |
| 138 | |
| 139 | return $input; |
| 140 | } |
| 141 | } |
| 142 |