security - Safety side of storing emoji into database

admin2025-01-07  5

I am storing emojis into a custom table and querying the content using wpdb variable. The database charset is utf8mb4 and collation is utf8mb4_general_ci

Emoji are stored as it is as the user enters them. What security issues can i face here and what things should i keep in mind to avoid any situation that could compromise my data. Also can user insert some random mysql/php code in input, should i sanitize it, encode it and then store. Also if i do encode at what stage should i decode it to present to ui.

I am storing emojis into a custom table and querying the content using wpdb variable. The database charset is utf8mb4 and collation is utf8mb4_general_ci

Emoji are stored as it is as the user enters them. What security issues can i face here and what things should i keep in mind to avoid any situation that could compromise my data. Also can user insert some random mysql/php code in input, should i sanitize it, encode it and then store. Also if i do encode at what stage should i decode it to present to ui.

Share Improve this question asked Jul 28, 2019 at 19:10 PawanPawan 1112 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

As with all user input, you will want to sanitize before storing the input, sanitize on display, and sanitize any user input used in queries. If you're limiting it strictly to emojis, I would also recommend validating and restricting input to only emojis.

  • PHP SQL Injection
  • Use Prepared Statements for SQL Injection Prevention
  • Use htmlspecialchars or htmlentities for XSS Prevention. Make sure your default_charset is set correctly, or specify the charset.
转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1736265499a1050.html

最新回复(0)