When a new user attempts to register without agreeing to the required Data Policy checkbox, an error message is displayed. However, this error message includes raw HTML code, making it unreadable for end users.
Additionally, the existing logic only handles URLs in the form of /register and fails when the URL includes parameters (e.g., /register?destination=/node/xxxx).
This results in a poor user experience and inconsistent handling of error messages.
Steps to reproduce
Navigate to the registration page with a query parameter in the URL, e.g., /register?destination=/node/xxxx.
Attempt to register without agreeing to the Data Policy checkbox.
Observe the error message displayed on the page. It includes raw HTML code, which is confusing for end users.
Proposed resolution
Refactor the data_policy_preprocess_status_messages() function to handle URLs with parameters (e.g., /register?destination=/node/xxxx) as well as anchor links.
Use preg_match() to ensure robust matching of the error message links and decode any HTML entities before rendering the error messages.
Remaining tasks
Update the regex in data_policy_preprocess_status_messages() to handle additional URL formats.
Test the updated implementation with various URL formats, including:
/register
/register?destination=/node/xxxx
URLs with additional query parameters.
Confirm that the error message no longer contains raw HTML and is rendered correctly.
Submit a patch for review.
User interface changes
Error messages on the registration page will now display as plain text, free of raw HTML, providing a better user experience.