198 |
return strip_tags(wordlinks($str)); |
return strip_tags(wordlinks($str)); |
199 |
} |
} |
200 |
|
|
201 |
|
function printAllowedHTML() { |
202 |
|
global $allowed_html; |
203 |
|
|
204 |
|
echo "Tillåten HTML:<br>\n"; |
205 |
|
|
206 |
|
foreach ($allowed_html as $onekey => $oneval) { |
207 |
|
echo "<$onekey"; |
208 |
|
|
209 |
|
foreach ($oneval as $twokey => $twoval) |
210 |
|
echo " <i>$twokey=</i>"; |
211 |
|
|
212 |
|
echo '> '; |
213 |
|
} |
214 |
|
|
215 |
|
echo "<br>\n"; |
216 |
|
} |
217 |
|
|
218 |
function new_check_html($string, $strip = '') { |
function new_check_html($string, $strip = '') { |
219 |
|
|
220 |
# Den här funktionen ser till att bara godkända HTML-element och deras |
# Den här funktionen ser till att bara godkända HTML-element och deras |
258 |
$attr = stripslashes(stripslashes($attr)); |
$attr = stripslashes(stripslashes($attr)); |
259 |
|
|
260 |
if (count($allowed_html[strtolower($element)]) == 0) |
if (count($allowed_html[strtolower($element)]) == 0) |
261 |
return "<$element>"; |
return "<$element>"; |
262 |
|
|
263 |
$attr = preg_replace('%(\s+([^=\s]+)'. # attributnamn |
$attr = preg_replace('%(\s+([^=\s]+)'. # attributnamn |
264 |
'(\s*=\s*'. # lika med |
'(\s*=\s*'. # lika med |
268 |
|
|
269 |
$attr = trim($attr); |
$attr = trim($attr); |
270 |
if ($attr != '') |
if ($attr != '') |
271 |
$attr = " $attr"; |
$attr = " $attr"; |
272 |
|
|
273 |
return "<$element$attr>"; |
return "<$element$attr>"; |
274 |
} |
} |
283 |
$wholeattribute = stripslashes($wholeattribute); |
$wholeattribute = stripslashes($wholeattribute); |
284 |
|
|
285 |
if ($allowed_html[strtolower($element)][strtolower($attributename)] != 1) |
if ($allowed_html[strtolower($element)][strtolower($attributename)] != 1) |
286 |
return ''; |
return ''; |
287 |
|
|
288 |
if ((!preg_match('%^\s+[^=\s]+\s*=\s*\'[^\']*\'$%', $wholeattribute)) and |
if ((!preg_match('%^\s+[^=\s]+\s*=\s*\'[^\']*\'$%', $wholeattribute)) and |
289 |
(!preg_match('%^\s+[^=\s]+\s*=\s*"[^"]*"$%', $wholeattribute)) and |
(!preg_match('%^\s+[^=\s]+\s*=\s*"[^"]*"$%', $wholeattribute)) and |
290 |
(preg_match('%["\']%', $wholeattribute))) |
(preg_match('%["\']%', $wholeattribute))) |
291 |
return ''; |
return ''; |
292 |
|
|
293 |
return $wholeattribute; |
return $wholeattribute; |
294 |
} |
} |