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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T22:12:02+00:00 2026-05-28T22:12:02+00:00

Per this excellent eye-opener article written by a sec. expert , I become quite

  • 0

Per this excellent eye-opener article written by a sec. expert , I become quite suspicious about the incoming strings – due to the fact that mysql_real_escape_string may be tricked…

The problem strictly stems from the multi-byte char sets such as GBK. If the user input is not a multi-byte input, then, no problems, no issues there as the mysql_real_escape_string will be good enough against SQL injection – provided that you do your basic data type validations properly.

I’m not saying multi-byte is evil… but if you do not have to deal with multibyte situations, then don’t. Stick to utf-8 if that works for you and just stay in utf-8 al the time… But the question is how? Cause, it’s the user who starts the process by sending you a non utf-8 string and perhaps a multi-byte string like GBK…

How do you make sure that you can successfully and reliably reject that user input then? From what I read/learn, it is impossible to know what char set the incoming user string is in. Then what?

In other words, how do you make sure that you are working with utf-8 user strings? I’m asking this because all the PHP filter/sanitization functions are all designed to deal with utf-8 input, they don’t know how to deal with multi-bytes? As the article points, protection measurements becomes the cause of the failure.

oooh, please don’t just say use prepared statements… aware of that excellent option allready.

  • 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-28T22:12:03+00:00Added an answer on May 28, 2026 at 10:12 pm

    This excellent eye-opener article has been written almost a decade ago and become a little obsolete.
    Since then things improved a little.
    PHP got a function to control mysql_real_escape_string() and make it really “taking into account the current character set of the connection” as documentation says.

    The problem strictly stems not from the multi-byte char sets such as GBK but rather from the character set misinterpretation. So, you just have to tell mysql, what character set you are working with. And thus there is no point in detecting multibyte strings at all.

    So, just set the proper character set using mysql_set_charset() and you will be safe.

    Here is a little demo I wrote on the topic.

    Also keep in mind that not every multibyte encoding is vulnerable. utf-8 is pretty safe. Otherwise we were suffering a zillion injections to-day.

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

Sidebar

Related Questions

As per this article : If you try and lock a non-recursive mutex twice
As per this article, every cluster has its own storage. A cluster hosts millions
As per this MSDN article: W3C Extended Log File Format (IIS 6.0) It says
I'm trying to build a Synergy AutoStart script as per this article , the
I've started to become a Good Citizen, as per this question here: Domain compatibility:
As per this article , I could generate tokens, configured Cassandra.yaml on both machines
As per this article , I've extended the System.Windows.Forms.WebBrowser class to implement custom error-handling.
Per this article , I've tried to get myself in the habit of fetching
Per this helpful article I have confirmed I have a connection pool leak in
Per this question (see comments near the bottom), I was wondering if anyone knows

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.