h5p-editor-php-library icon indicating copy to clipboard operation
h5p-editor-php-library copied to clipboard

Replace deprecated FILTER_SANITIZE_STRING

Open otacke opened this issue 2 years ago • 2 comments

FILTER_SANITIZE_STRING is deprecated since PHP 8.0

otacke avatar Apr 29 '22 18:04 otacke

Just came to this PR from elsewhere...

guessing if the replacement proposed here is enough, or we also have to apply for strip_tags(), as far as the, now deprecated in php 8.1, FILTER_SANITIZE_STRING also performed such stripping.

So, basically, in order to get 99% the same results than before, any of this should be ok, I think they are the same:

  • filter_var(strip_tags($input), FILTER_SANITIZE_FULL_SPECIAL_CHARS, FILTER_FLAG_NO_ENCODE_QUOTES))
  • htmlspecialchars(strip_tags($input), ENT_NOQUOTES))

Link: https://3v4l.org/7rphp (to see the behaviour both without and with FILTER_FLAG_NO_ENCODE_QUOTES)

Not sure how that tags stripping is important or no, just sharing that the original was performing it.

Ciao :-)

stronk7 avatar Nov 15 '22 10:11 stronk7

Just checking if there are any updates on this PR.

andrewnicols avatar Feb 07 '23 02:02 andrewnicols

Looks good, thanks :)

thomasmars avatar Sep 06 '24 08:09 thomasmars