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 7399397
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T04:03:20+00:00 2026-05-29T04:03:20+00:00

I want to escape for XSS in an HTML context, and so far I

  • 0

I want to escape for XSS in an HTML context, and so far I treat the <, >, and " characters.
Apparently it is recommended to escape the ampersand as well, but why? (Other than for keeping the HTML valid, let’s assume that this is not an issue)

So what I am asking is:
When I escape <, > and ", can someone demonstrate how the ampersand can still allow an XSS attack in an HTML context?

Cheers!

  • 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-29T04:03:21+00:00Added an answer on May 29, 2026 at 4:03 am

    You should really take a look at the OWASP XSS Prevention Cheat Sheet.

    You should escape & because it can be used to circumvent other defenses. Consider this code:

    <button onclick="confirm('Do you really want to delete <%= data_from_user; %> ?'">Delete</button>
    

    To defend against XSS inside the onclick event handler, the developer escapes ‘, “, < and > in data_from_user and thinks everything is ok. The problem is that if the attacker types &#39; which passes the escaping, but ends up allowing the attacker to run javascript.

    Example here: http://erlend.oftedal.no/blog/?blogid=124

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

Sidebar

Related Questions

I've been using Apache's StringEscapeUtils for HTML entities, but if you want to escape
Hi I want to insert all escape characters in a column in MySQL. I
i want to escape some HTML in JavaScript. How can I do that?
i have field in databaase. which contains special characters. i want to escape these
I want to escape '' and all other wild chars in program name and
I want to supply escape characters for my C program as command line arguments:
I want do replace why this code don't work? MessageBox.Show( Regex.Replace(Regex.Escape(@c:\www\html), Regex.Escape(@c:\www\), , RegexOptions.IgnoreCase));
Before displaying user posts I run them though Sanitize::html() to escape all html. But
first question ever here on stackoverflow: i want to escape html inside php AND
i have the following problem. I want to escape all special characters in a

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.