soerennb/extplorer

FILTER_SANITIZE_STRING is deprecated (and other warnings)

atesin opened this issue · 2 comments

EDIT: this issue could be related to #18

each time i refreshed the view (click a folder icon or file tab, etc) my php log floods with about 100 lines of:

[date time zone] PHP Deprecated:  Constant FILTER_SANITIZE_STRING is deprecated in /my/htdocs/extplorer/libraries/inputfilter.php on line 323

... using:

  • extplorer 2.1.15
  • php 8.1.8
  • nginx 1.22.0
  • fedora linux 36
  • linux 5.18.13-200.fc36.x86_64

i tried editing the sources by changing to htmlspecialchars() as recommended by php, but views were displayed empty instead... so as a workaround i added an arroba @ to prevent my logs grow too much and my disks get full so quickly, even i don't feel so comfotable with this because i am afraid something could break in the future

this patch works now ... maybe i did something wrong before... you need to replace
filter_var($value, FILTER_SANITIZE_STRING)
with
$value = htmlspecialchars($value)

more warnings:

[date time zone] PHP Deprecated:  strtolower(): Passing null to parameter #1 ($string) of type string is deprecated in /my/htdocs/extplorer/include/functions.php on line 720
[date time zone] PHP Deprecated:  strtolower(): Passing null to parameter #1 ($string) of type string is deprecated in /my/htdocs/extplorer/include/functions.php on line 721

this can be fixed easily by prepending an arroba "@" to the function (anyway, any other variable type will be different to string 'xmlhttprequest'), by changing this...

function ext_isXHR() {
        return strtolower(extGetParam($_SERVER,'HTTP_X_REQUESTED_WITH')) == 'xmlhttprequest'
                || strtolower(extGetParam($_POST,'requestType')) == 'xmlhttprequest';
}

with this...

function ext_isXHR() { // PATCHED: see https://github.com/soerennb/extplorer/issues/25
        return @strtolower(extGetParam($_SERVER,'HTTP_X_REQUESTED_WITH')) == 'xmlhttprequest'
                || @strtolower(extGetParam($_POST,'requestType')) == 'xmlhttprequest';
}