Closed jrfnl closed 6 years ago
For this sniff we can most likely use the token T_BAD_CHARACTER
i would like to try this.
From: https://github.com/WPTRT/WordPress-Coding-Standards/pull/103#issuecomment-274278772
I spoke to Otto and the reason this was added in the Theme Check was to check for Byte Order Mark. Explanation. This is now being checked with Generic.Files.ByteOrderMark
The check was made a bit looser to try to catch other issues too.
I did a bit of research, non printable characters are things like line breaks. In order for this sniff to work we would need to think of places where it does not make sense to have non printable characters. I am not sure how many places there are.
More of the ASCII codes can be found in the links 1-31 and 127-159 are the invisible characters. http://ascii.cl/htmlcodes.htm http://www.ascii-code.com/
It basically needs to become clear whether just checking for the BOM is enough, or checking for more non-printables is needed.
If the latter, PR #103 contains the basic principle of a sniff for that, but should in that case probably be pulled upstream, either in WPCS or - even better - in PHPCS itself.
Rule type:
Warning
Rule:
Ref: https://make.wordpress.org/themes/handbook/review/required/theme-check-plugin/#info
Theme check file covering this rule:
https://github.com/WordPress/theme-check/blob/master/checks/nonprintable.php
Notes for implementation:
To do: