[英]Joomla | How to filter input string containing html tags
I have a joomla component and trying to filter HTML content from the users input. 我有一个joomla组件,并尝试从用户输入中过滤HTML内容。
$input = $app->input->post->getRaw('question');
This will getting me the RAW html. 这将使我获得RAW html。
How can I check (The joomla way or custom php function) is it safe before saving into my database? 在保存到数据库之前,如何检查(joomla方式或自定义php函数)是否安全?
Thanks! 谢谢!
Joomla has an automatic function for that, please check System -> Global Configuration -> Text Filters
and set the appropriate filtering for your user group. Joomla具有自动功能,请检查
System -> Global Configuration -> Text Filters
并为您的用户组设置适当的过滤System -> Global Configuration -> Text Filters
。
If you want to do that with php, you could use strip_tags() function. 如果要使用php进行操作,则可以使用strip_tags()函数。 Your result would be like:
您的结果将是:
$input = strip_tags($app->input->post->getRaw('question'));
Good Luck! 祝好运!
You can convert the input to a string, striping all HTML tags/attributes, this way: 您可以通过以下方式将输入转换为字符串,剥离所有HTML标记/属性:
$jinput = JFactory::getApplication()->input;
$input = $jinput->get('question', 'default_value', 'html');
Official Documentation: Retrieving request data using JInput 官方文档: 使用JInput检索请求数据
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.