filters - How to strip out javascript in wp_posts `post_content`

My website is undergoing an SQL injection attack redirecting to ad site dolohen[dot]com.I need to strip out the javascri

My website is undergoing an SQL injection attack redirecting to ad site dolohen[dot]com.

I need to strip out the javascript before it is served up.

Is there a filter I can add or update to remove everything between tags in wp_posts post_content

I am new to programming wordpress but not to sql and databases.

Its a bit confusing because some people want to put javascript in posts but can't. Yet these SQL injectors seem to do it at will!

Thanks Phil

My website is undergoing an SQL injection attack redirecting to ad site dolohen[dot]com.

I need to strip out the javascript before it is served up.

Is there a filter I can add or update to remove everything between tags in wp_posts post_content

I am new to programming wordpress but not to sql and databases.

Its a bit confusing because some people want to put javascript in posts but can't. Yet these SQL injectors seem to do it at will!

Thanks Phil

Share Improve this question edited Oct 4, 2019 at 19:15 JakeParis 6633 gold badges7 silver badges22 bronze badges asked Oct 3, 2019 at 17:36 PHILBOPHILBO 12 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

If the javascript code is actually embedded in the post content, you could use php filters such as the_content to remove script tags. But that will strip it out at runtime, every time the page is loaded. If this is your situation, then you'd be better off stripping it out of the wp_posts.post_content table/column from the database.

If you want to quickly strip out the content just for display, you can use the the_content filter, like so (in your theme's functions file)

add_filter('the_content', function($content){
    return wp_kses_post( $content );
});

But again, this will run every time the page is loaded. It's more of a short term fix.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745105321a4611521.html

相关推荐

  • filters - How to strip out javascript in wp_posts `post_content`

    My website is undergoing an SQL injection attack redirecting to ad site dolohen[dot]com.I need to strip out the javascri

    13小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信