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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T16:00:12+00:00 2026-05-17T16:00:12+00:00

I have implemented a search engine in C for my html website. My entire

  • 0

I have implemented a search engine in C for my html website. My entire web is programmed in C.

I understand that html input sanitization is necessary because an attacker can input these 2 html snippets into my search page to trick my search page into downloading and displaying foreign images/scripts (XSS):

<img src="path-to-attack-site"/>
<script>...xss-code-here...</script>

Wouldn’t these attacks be prevented simply by searching for ‘<‘ and ‘>’ and stripping them from the search query ? Wouldn’t that render both scripts useless since they would not be considered html ? I’ve seen html filtering that goes way beyond this where they filter absolutely all the JavaScript commands and html markup !

  • 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-17T16:00:12+00:00Added an answer on May 17, 2026 at 4:00 pm

    Input sanitisation is not inherently ‘necessary’.

    It is a good idea to remove things like control characters that you never want in your input, and certainly for specific fields you’ll want specific type-checking (so that eg. a phone number contains digits).

    But running escaping/stripping functions across all form input for the purpose of defeating cross-site-scripting attacks is absolutely the wrong thing to do. It is sadly common, but it is neither necessary nor in many cases sufficient to protect against XSS.

    HTML-escaping is an output issue which must be tackled at the output stage: that is, usually at the point you are templating strings into the output HTML page. Escape < to &lt;, & to &amp;, and in attribute values escape the quote you’re using as an attribute delimiter, and that’s it. No HTML-injection is possible.

    If you try to HTML-escape or filter at the form input stage, you’re going to have difficulty whenever you output data that has come from a different source, and you’re going to be mangling user input that happens to include <, & and " characters.

    And there are other forms of escaping. If you try to create an SQL query with the user value in, you need to do SQL string literal escaping at that point, which is completely different to HTML escaping. If you want to put a submitted value in a JavaScript string literal you would have to do JSON-style escaping, which is again completely different. If you wanted to put a value in a URL query string parameter you need URL-escaping, not HTML-escaping. The only sensible way to cope with this is to keep your strings as plain text and escape them only at the point you output them into a different context like HTML.

    Wouldn’t these attacks be prevented simply by searching for ‘<‘ and ‘>’ and stripping them from the search query ?

    Well yes, if you also stripped ampersands and quotes. But then users wouldn’t be able to use those characters in their content. Imagine us trying to have this conversation on SO without being able to use <, & or "! And if you wanted to strip out every character that might be special when used in some context (HTML, JavaScript, CSS…) you’d have to disallow almost all punctuation!

    < is a valid character, which the user should be permitted to type, and which should come out on the page as a literal less-than sign.

    My entire web is programmed in C.

    I’m so sorry.

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

Sidebar

Related Questions

In our desktop application, we have implemented a simple search engine using an inverted
How does images.google.com render its frames?? I have two servers, that have external web
I have implemented cloaking for search engines. In my category pages, it will display
I have a Google Custom Search Engine on our site and I have recently
i want to implement a small search engine , i have index page where
I have a web app, that consumes a web service. The main page runs
I have an app very similar to address book of iphone. The entire search
I have a new web app that is packaged as a WAR as part
I have implemented a binary search tree and I want to add more functionality
I have implemented SOLR for my search results. Now I want to display results

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.