A
A
Alexey2015-09-25 18:45:04
PHP
Alexey, 2015-09-25 18:45:04

Which validator to use for my needs?

We need both a validator and a "cleaner" of the code from extra characters and the like. The tasks are as follows:
Type fields: article title, article description, numeric data, email, password, comments.
would this be enough?

$source = stripslashes( $source );
    $source = preg_replace( "#<script#i", "&lt;script", $source );
    $source = preg_replace_callback( "#<iframe(.+?)src=['\"](.+?)['\"](.*?)>(.*?)</iframe>#is", array( &$this, 'check_frame'), $source );
    $source = str_ireplace( "<iframe", "&lt;iframe", $source );
    $source = str_ireplace( "</iframe>", "&lt;/iframe&gt;", $source );
    $source = str_replace( "<?", "&lt;?", $source );
    $source = str_replace( "?>", "?&gt;", $source );
    $source = addslashes( $source );
    return $source;

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Taratin, 2015-09-25
@Taraflex

Not enough.
The simplest option.
https://github.com/bezumkin/Jevix

D
Denis, 2015-09-25
@prototype_denis

https://github.com/ezyang/htmlpurifier

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question