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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:01:24+00:00 2026-06-15T10:01:24+00:00

Was looking over a developer’s code. He did something that I have never seen

  • 0

Was looking over a developer’s code. He did something that I have never seen before in a Python application. His background is in PHP and is just learning python, so I don’t know if this is perhaps a holdover from the different system architectures that he is used to working with.

He told me that the purpose of this code is to prevent the user from attacking the application via code insertion. I’m pretty sure this is unnecessary for our use case since we are never evaluating the data as code, but I just wanted to make sure and ask the community.

# Import library
from cgi import escape

# Get information that the client submitted
fname   = GET_request.get('fname',   [''] )[0]

# Make sure client did not submit malicious code <- IS THIS NECESSARY?
if fname:
    fname = escape(fname)
  • Is this typically necessary in a Python application?
  • In what situations is it necessary?
  • In what situations is it not necessary?
  • 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-06-15T10:01:25+00:00Added an answer on June 15, 2026 at 10:01 am

    If user input is going into a database, or anywhere else it might be executed, then code injection could be a problem.

    This question asks about ways to prevent code injection in php, but the principle is the same – SQL queries containing malicious code get executed, potentially doing things like deleting all your data.

    The escape function converts <, > and & characters into html-safe sequences.

    From those two links it doesn’t look like escape() is enough on it’s own, but something does need to be done to stop malicious code. Of course this may well be being taken care of elsewhere in your code.

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

Sidebar

Related Questions

I was looking over some code that another developer wrote and found this: Private
I have been looking over this code for the past hour, I cant see
I have inherited a classic asp application that had over 800 files in the
I have been looking over the internet for a while about this, but it
I was looking over the code for qunit. My question is why would you
I have a little / weird behaviour here and Im looking over internet and
I have been looking all over the internet and i found some good guides
I have been looking all over for this. I have two seperate prpt files
I am an windows developer with over 15 years experience. I have just started
I'm using .net 2.0. This is a project that I have taken over for

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.