By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,060 Members | 1,878 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,060 IT Pros & Developers. It's quick & easy.

preg_match may not fail on 4 and 5 octet sequences, even though they are not supporte

oranoos3000
100+
P: 107
hi
i read below text and i understand what say but i dont identify meaning of this setence
preg_match may not fail on 4 and 5 octet sequences, even though they are not supported by the specification.


Checks whether a string is valid UTF-8.

All functions designed to filter input should use drupal_validate_utf8 to ensure they operate on valid UTF-8 strings to prevent bypass of the filter.

When text containing an invalid UTF-8 lead byte (0xC0 - 0xFF) is presented as UTF-8 to Internet Explorer 6, the program may misinterpret subsequent bytes. When these subsequent bytes are HTML control characters such as quotes or angle brackets, parts of the text that were deemed safe by filters end up in locations that are potentially unsafe; An onerror attribute that is outside of a tag, and thus deemed safe by a filter, can be interpreted by the browser as if it were inside the tag.

This function exploits preg_match behaviour (since PHP 4.3.5) when used with the u modifier, as a fast way to find invalid UTF-8. When the matched string contains an invalid byte sequence, it will fail silently.

preg_match may not fail on 4 and 5 octet sequences, even though they are not supported by the specification.

The specific preg_match behaviour is present since PHP 4.3.5.
Parameters

$text The text to check.
Return value

TRUE if the text is valid UTF-8, FALSE if not.

would you please help me.
Sep 15 '10 #1
Share this Question
Share on Google+
1 Reply


P: 13
Sounds like it does not always fail on sequences that is not part of the UTF-8 specification.

Ref table 5-1 under pt 5.9.4 here Character Encoding

(note to self: test this soon)
Sep 19 '10 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Browse more PHP Questions on Bytes