Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 928127
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T19:57:38+00:00 2026-05-15T19:57:38+00:00

I want to filter my output to make it safer from Cross site scripting

  • 0

I want to filter my output to make it safer from Cross site scripting (XSS) attacks so I am filtering output with htmlentities. The problem is, I am trying to make my application utf8 compatible so when I enter something like ಠ_ಠ I would like it to be maintained when retrieved from the database. Is there a simple solution to achieve this? Thanks in advance for any advice.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T19:57:38+00:00Added an answer on May 15, 2026 at 7:57 pm

    Three things

    1. HTML sanitization is an output escaping task, not input filtering. You should not do this task prior to storage, you should only do it prior to display.
    2. If you are trying to prevent XSS, you don’t need to use htmlentities() – htmlspecialchars() is sufficient. htmlentities() is used only when trying to render a content from a character-encoding that is disparate from native encoding.
    3. Both functions accept a character encoding as the third argument.

    So, finally:

    echo htmlspecialchars( $content, ENT_QUOTES, 'UTF-8' );
    

    Where if you used ENT_NOQUOTES you could be vulnerable to some types of XSS.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to filter logcat output from a real device (not an emulator) by
I want to get filter column string from below Data. URL PreFix OutPut ConcatStrings
Using vbscript, how can I filter the output from a WMI Query? I want
I want to filter rows from a data.frame based on a logical condition. Let's
I want to filter elements from a list of lists, and iterate over the
To filter a table output of selected entries from a single table i would
I want to filter records from given file based on some criteria,i want my
I want to try to filter all operators and operands including floating points from
I want tpage to redirect the output to a different file. The redirect filter
I want to write to a file from my filter and then be able

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.