Skip to content
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

Use a custom htmlescape() function to handle unexpected null values #17936

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

cedric-anne
Copy link
Member

Checklist before requesting a review

Please delete options that are not relevant.

  • I have read the CONTRIBUTING document.
  • I have performed a self-review of my code.
  • I have added tests that prove my fix is effective or that my feature works.

Description

Fixes #17933.

There are many places in our code where htmlspecialchars() may be call for a null value (or even an integer, a float, ...). Instead of using the ?? '' to fix occurences that triggers a deprecation notice, I propose to use a custom htmlescape() function that ensures that non-string legitimate values are correctly handled.

"\" " . (!$_SESSION['ldap_import']['basedn'] ? "disabled" : "") . ">";
echo "</td></tr>";

echo "<tr><td class='text-end'><label for='ldap_filter'>" . __('Search filter for users') . "</label></td><td colspan='3'>";
echo "<input type='text' class='form-control' id='ldap_filter' name='ldap_filter' value=\"" .
htmlspecialchars($_SESSION['ldap_import']['ldap_filter'], ENT_QUOTES) . "\">";
htmlescape($_SESSION['ldap_import']['ldap_filter'], ENT_QUOTES) . "\">";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
htmlescape($_SESSION['ldap_import']['ldap_filter'], ENT_QUOTES) . "\">";
htmlspecialchars($_SESSION['ldap_import']['ldap_filter'] ?? '', ENT_QUOTES) . "\">";

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CS is complaining about several issues like this one. LGTM appart of that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants