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

Strip HTML tags from page description #3490

Merged
merged 3 commits into from Mar 9, 2024

Conversation

samerton
Copy link
Member

@samerton samerton commented Mar 8, 2024

No description provided.

partydragen
partydragen previously approved these changes Mar 8, 2024
@samerton samerton merged commit d8d2ad5 into develop Mar 9, 2024
14 checks passed
@samerton samerton deleted the bugfix/html-in-page-description branch March 9, 2024 20:40
@Derkades
Copy link
Member

Derkades commented Mar 10, 2024

Why addslashes? Isn't that function specifically for PHP strings? I think htmlspecialchars() is the right function to use here.

@samerton
Copy link
Member Author

Why addslashes? Isn't that function specifically for PHP strings? I think htmlspecialchars() is the right function to use here.

This is just the page description so it shouldn't have any HTML inside - we have already stripped HTML tags, now we need to ensure that quotation marks " are also escaped so that they do not interfere with the meta tags

@Derkades
Copy link
Member

Derkades commented Mar 13, 2024

Still, addslashes is for PHP which means it for example escapes " to \" while htmlspecialchars (with the default flags including ENT_QUOTES) is meant for HTML which means it correctly escapes " to ". addslashes might coincidentally seem to work fine but it probably has subtle security holes. It's like using urlencode to escape for a SQL query. The addslashes documentation (and comments) warn about this.

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

Successfully merging this pull request may close these issues.

None yet

3 participants