Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

What does kill octets mean in WordPress's sanitize_user()?

In sanitize_user() there is a line of code which is commented "Kill octets":

// Kill octets.
$username = preg_replace( '|%([a-fA-F0-9][a-fA-F0-9])|', '', $username );

I thought that octets were essentially bytes which encode unicode characters (although I know many unicode characters are encoded by more than one byte) and therefore I do not understand why they need to be ‘killed’.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

sanitize_user() removes characters and sequences that aren’t allowed in WordPress user names. User names like Mickey%20Mouse aren’t allowed. That user name attempts to include a space by including the %20 space octet.

In general, sanitize operations strip out disallowed data.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading