Skip to content

Replace deprecated filter FILTER_SANITIZE_STRING #5540

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion system/Helpers/cookie_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function get_cookie($index, bool $xssClean = false)
{
$prefix = isset($_COOKIE[$index]) ? '' : config(App::class)->cookiePrefix;
$request = Services::request();
$filter = $xssClean ? FILTER_SANITIZE_STRING : FILTER_DEFAULT;
$filter = $xssClean ? FILTER_SANITIZE_FULL_SPECIAL_CHARS : FILTER_DEFAULT;

return $request->getCookie($prefix . $index, $filter);
}
Expand Down
8 changes: 4 additions & 4 deletions user_guide_src/source/incoming/incomingrequest.rst
Original file line number Diff line number Diff line change
Expand Up @@ -399,15 +399,15 @@ The methods provided by the parent classes that are available are:
The second optional parameter lets you run the data through the PHP's
filters. Pass in the desired filter type as the second parameter::

$request->getVar('some_data', FILTER_SANITIZE_STRING);
$request->getVar('some_data', FILTER_SANITIZE_FULL_SPECIAL_CHARS);

To return an array of all POST items call without any parameters.

To return all POST items and pass them through the filter, set the
first parameter to null while setting the second parameter to the filter
you want to use::

$request->getVar(null, FILTER_SANITIZE_STRING);
$request->getVar(null, FILTER_SANITIZE_FULL_SPECIAL_CHARS);
// returns all POST items with string sanitation

To return an array of multiple POST parameters, pass all the required keys as an array::
Expand All @@ -417,7 +417,7 @@ The methods provided by the parent classes that are available are:
Same rule applied here, to retrieve the parameters with filtering, set the second parameter to
the filter type to apply::

$request->getVar(['field1', 'field2'], FILTER_SANITIZE_STRING);
$request->getVar(['field1', 'field2'], FILTER_SANITIZE_FULL_SPECIAL_CHARS);

.. php:method:: getGet([$index = null[, $filter = null[, $flags = null]]])

Expand Down Expand Up @@ -489,7 +489,7 @@ The methods provided by the parent classes that are available are:
This method is identical to ``getPost()`` and ``getGet()``, only it fetches cookie data::

$request->getCookie('some_cookie');
$request->getCookie('some_cookie', FILTER_SANITIZE_STRING); // with filter
$request->getCookie('some_cookie', FILTER_SANITIZE_FULL_SPECIAL_CHARS); // with filter

To return an array of multiple cookie values, pass all the required keys as an array::

Expand Down