Why is sanitize_text_field() selectively trimming data?

Can anyone explain it?

The official docs for that function say it strips percent encoded characters.

  • Checks for invalid UTF-8,
  • Converts single < characters to entities
  • Strips all tags
  • Removes line breaks, tabs, and extra whitespace
  • Strips percent-encoded characters

https://developer.wordpress.org/reference/functions/sanitize_text_field/

It looks like it’s stripped out %ad and it has nothing to do with instances or leading/trailing, that function doesn’t understand that it’s a CSV etc, % probably isn’t the best character to use for this.

Why just the %ad though? In this case it’s the URL encoded value for ­ aka a soft hyphen, or &shy;.

See https://www.w3schools.com/tags//ref_urlencode.asp for a more comprehensive table.

techhipbettruvabetnorabahisbahis forumutaraftarium24edueduseduseduedusedueduseduseduedus