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

  • Home
  • SEARCH
  • 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 3234002
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T17:20:30+00:00 2026-05-17T17:20:30+00:00

Output or Input filtering? I constantly see people writing filter you inputs, sanitize your

  • 0

Output or Input filtering?

I constantly see people writing “filter you inputs”, “sanitize your inputs”, don’t trust user data, but I only agree with the last one, where I consider trusting any external data a bad idea even if it is internal relative to the system.

Input filtering:
The most common that I see.
Take the form post data or any other external source of information and define some boundaries when saving it, for example making sure text is text, numbers are numbers, that sql is valid sql, that html is valid html and that it does not contain harmful markup, and then you save the “safe” data in the database.

But when fetching data you just use the raw data from the database.

In my personal opinion, the data is never really safe.
Although it sounds easy, just filter everything you get from forms and url’s, in reality it is much harder than that, it might be safe for one language but not another.

Output filtering:
When doing it this way I save the raw unaltered data, whatever it might be, with prepared statements into the database and then filter out the problematic code when accessing the data, this has it’s own advantages:
This adds a layer between html and the server side script.
which I consider to be data access separation of sorts.

Now data is filtered depending on the context, for example I can have the data from the database presented in a html document as plain-escaped-text, or as html or as anything anywhere.

The drawbacks here are that you must not ever forget to add the filtering which is a little bit harder than with input filtering and it uses a bit more CPU when providing data.

This does not mean that you don’t need to do validation checks, you still do, it’s just that you don’t save the filtered data, you validate it and provide the user with a error message if the data is somehow invalid.

So instead of going with “filter your inputs” maybe it should be “validate your inputs, filter your outputs”.

so should I go with “Input validation and filtering” or “Input validation and output filtering”?

  • 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-17T17:20:31+00:00Added an answer on May 17, 2026 at 5:20 pm

    There is no generic “filtering” for input and output.

    Validate your input, escape your output. How you do this depends on context.

    Validation is about making sure input falls within sensible ranges, like the length of strings, the numericality of dollar amounts or that a record being updated is owned by the user performing the update. This is about maintaining the logical consistency of your data and preventing people from doing things like zeroing the price of a product they are purchasing or deleting records they shouldn’t have access to. It has nothing to do with “filtering” or escaping specific characters in your input.

    Escaping is a matter of context, and only really makes sense when you’re doing something with data that can be poisoned by injecting certain characters. Escape HTML characters in data you send to the browser. Escape SQL characters in data you send to the database. Escape quotes when you’re writing data inside JavaScript <script> tags. Just be conscious of how the data you’re dealing with is going to be interpreted by the system you’re passing it to and escape accordingly.

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

Sidebar

Related Questions

Is there a way to use these operators to input and output binary data?
I have two objects, let's call them Input and Output Input has properties Input_ID
I have an XML input file and I'm trying to output the result of
I'm trying something like this Output.py print Hello Input.py greeting = raw_input(Give me the
Are there any known hash algorithms which input a vector of int's and output
Any good suggestions? Input will be the name of a header file and output
I'm trying to run a process and do stuff with its input, output and
I'm using Zend_Form to output a set group of checkboxes: <label style=white-space: nowrap;><input type=checkbox
Here is some dprofpp -I output, for almost the same program on different input
I am processing a user input from the public with a javascript WYSIWYG editor

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.