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

prevent xss filter html usage / allowed html tags #17

Closed
sinanisler opened this issue May 8, 2022 · 1 comment
Closed

prevent xss filter html usage / allowed html tags #17

sinanisler opened this issue May 8, 2022 · 1 comment
Assignees
Labels
enhancement New feature or request security

Comments

@sinanisler
Copy link
Owner

sinanisler commented May 8, 2022

prevent xss filter html usage

// Create function which allows more tags within comments
function filter_html_usage() {
  global $allowedtags;
  $allowedtags['pre'] = array('class'=>array());
  $allowedtags['p'] = array('class'=>array());
  $allowedtags['code'] = array('class'=>array());
  $allowedtags['strong'] = array('class'=>array());
  $allowedtags['href'] = array('class'=>array());
}
 
// Add WordPress hook to use the function
add_action('init', 'filter_html_usage',11);
@sinanisler sinanisler added enhancement New feature or request security labels May 8, 2022
@sinanisler sinanisler self-assigned this May 8, 2022
@sinanisler sinanisler changed the title prevent xss filter html usage prevent xss filter html usage / allowed html tags May 8, 2022
@sinanisler
Copy link
Owner Author

@serkanalgur is this good or we should use a better way?

I tested it with the <script> tag it works.

SiForum/functions.php

Lines 53 to 76 in ce84b74

function filter_html_usage() {
global $allowedtags;
$allowedtags['code'] = array('class'=>array());
$allowedtags['pre'] = array('class'=>array());
$allowedtags['p'] = array('class'=>array());
$allowedtags['strong'] = array('class'=>array());
$allowedtags['href'] = array('class'=>array());
$allowedtags['a'] = array('class'=>array());
$allowedtags['ul'] = array('class'=>array());
$allowedtags['li'] = array('class'=>array());
$allowedtags['i'] = array('class'=>array());
$allowedtags['h1'] = array('class'=>array());
$allowedtags['h2'] = array('class'=>array());
$allowedtags['h3'] = array('class'=>array());
$allowedtags['b'] = array('class'=>array());
$allowedtags['abbr'] = array('class'=>array());
$allowedtags['acronym'] = array('class'=>array());
$allowedtags['blockquote'] = array('class'=>array());
$allowedtags['cite'] = array('class'=>array());
$allowedtags['em'] = array('class'=>array());
}
// Add WordPress hook to use the function
add_action('init', 'filter_html_usage',11);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request security
Projects
None yet
Development

No branches or pull requests

2 participants