1 | <?php namespace Gears\String\Methods; |
||
16 | trait Html |
||
17 | { |
||
18 | /** |
||
19 | * Convert all HTML entities to their applicable characters. |
||
20 | * |
||
21 | * @link http://php.net/manual/en/function.html-entity-decode.php |
||
22 | * |
||
23 | * @param int|null $flags Optional flags |
||
24 | * |
||
25 | * @return static String after being html decoded. |
||
26 | */ |
||
27 | public function htmlDecode($flags = ENT_COMPAT) |
||
39 | |||
40 | /** |
||
41 | * Convert all applicable characters to HTML entities. |
||
42 | * |
||
43 | * @link http://php.net/manual/en/function.htmlentities.php |
||
44 | * |
||
45 | * @param int|null $flags Optional flags. |
||
46 | * |
||
47 | * @param bool $doubleEncode When double_encode is turned off PHP |
||
48 | * will not encode existing html entities. |
||
49 | * The default is to convert everything. |
||
50 | * |
||
51 | * @return static String after being html encoded. |
||
52 | */ |
||
53 | public function htmlEncode($flags = null, $doubleEncode = true) |
||
68 | |||
69 | /** |
||
70 | * Sanitizes data so that Cross Site Scripting Hacks can be prevented. |
||
71 | * |
||
72 | * This method does a fair amount of work and it is extremely thorough, |
||
73 | * designed to prevent even the most obscure XSS attempts. Nothing is ever |
||
74 | * 100 percent foolproof, of course, but I haven't been able to get anything |
||
75 | * passed the filter. |
||
76 | * |
||
77 | * > NOTE: Should only be used to deal with data upon submission. |
||
78 | * > It's not something that should be used for general runtime processing. |
||
79 | * |
||
80 | * __In other words it is still critically important |
||
81 | * to escape anything that you output!!!__ |
||
82 | * |
||
83 | * This uses a packaged version of the Anti XSS Library from CodeIgniter. |
||
84 | * @link https://github.com/voku/anti-xss |
||
85 | * |
||
86 | * @return static |
||
87 | */ |
||
88 | public function htmlXssClean() |
||
110 | |||
111 | /** |
||
112 | * Strip HTML and PHP tags from a string. |
||
113 | * |
||
114 | * This function tries to return a string with all NULL bytes, |
||
115 | * HTML and PHP tags stripped from a given str. |
||
116 | * |
||
117 | * @param string|null $allowableTags You can use the optional second |
||
118 | * parameter to specify tags which |
||
119 | * should not be stripped. |
||
120 | * |
||
121 | * @return static |
||
122 | */ |
||
123 | public function htmlStripTags($allowableTags = null) |
||
130 | } |
||
131 |