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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T05:56:52+00:00 2026-06-13T05:56:52+00:00

From this excellent UTF-8 all the way through question, I read about this: Unfortunately,

  • 0

From this excellent “UTF-8 all the way through” question, I read about this:

Unfortunately, you should verify every submitted string as being valid
UTF-8 before you try to store it or use it anywhere. PHP’s
mb_check_encoding() does the trick, but you have to use it
religiously. There’s really no way around this, as malicious clients
can submit data in whatever encoding they want, and I haven’t found a
trick to get PHP to do this for you reliably.

Now, I’m still learning the quirks of encoding, and I’d like to know exactly what malicious clients can do to abuse encoding. What can one achieve? Can somebody give an example? Let’s say I save the user input into a MySQL database, or I send it through e-mail, how can a user create harm if I do not use the mb_check_encoding functionality?

  • 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-13T05:56:54+00:00Added an answer on June 13, 2026 at 5:56 am

    how can a user create harm if I do not use the mb_check_encoding functionality?

    This is about overlong encodings.

    Due to an unfortunate quirk of UTF-8 design, it is possible to make byte sequences that, if parsed with a naïve bit-packing decoder, would result in the same character as a shorter sequence of bytes – including a single ASCII character.

    For example the character < is usually represented as byte 0x3C, but could also be represented using the overlong UTF-8 sequence 0xC0 0xBC (or even more redundant 3- or 4-byte sequences).

    If you take this input and handle it in a Unicode-oblivious byte-based tool, then any character processing step being used in that tool may be evaded. The canonical example would be submitting 0x80 0xBC to PHP, which has native byte strings. The typical use of htmlspecialchars to HTML-encode the character < would fail here because the expected byte sequence 0x3C is not present. So the output of the script would still include the overlong-encoded <, and any browser reading that output could potentially read the sequence 0x80 0xBC 0x73 0x63 0x72 0x69 0x70 0x74 as <script and hey presto! XSS.

    Overlongs have been banned since way back and modern browsers no longer permit them. But this was a genuine problem for IE and Opera for a long time, and there’s no guarantee every browser is going to get it right in future. And of course this is only one example – any place where a byte-oriented tool processes Unicode strings you’ve potentially got similar problems. The best approach, therefore, is to remove all overlongs at the earliest input phase.

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

Sidebar

Related Questions

Just learning about State monad from this excellent tutorial . However, when I tried
From this question & the answers - What is the correct answer for cout
From this question I learned Double.NaN is not equal to itself. I was verifying
Thanks to this excellent tutorial , I know how to read a string (in
Following on from the excellent answer to my previous question: Linq Entity Framework generic
I have read this excellent blog entry on the woes of strong naming and
I read a while back this excellent answer by @Bill Karwin: https://stackoverflow.com/a/1313293/317889 This pretty
I would like to convert a few Python lines on Ruby, from this excellent
This question follows on from this vim search question I have a setting in
This is taken from Jon Skeet's excellent personal C# site ( http://www.yoda.arachsys.com/csharp/ ): StringBuilder

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.