- CONFIGURATION AND ENVIRONMENT
- BUGS AND LIMITATIONS
- BUG REPORTING
- TEST AND QUALITY
- DEPENDENCIES AND REQUIREMENTS
- SEE ALSO
- LICENSE AND COPYRIGHT
Perl::Critic::Policy::RegularExpressions::RequireDefault - Always use the
/aa modifier with regular expressions.
This documentation describes version 1.01
This policy has no affiliation
This poliy aims to help enforce using Perl's protective measures against security vulnerabilities related to Unicode, such as:
Character and String Transformation Vulnerabilities
/aa modifiers standing for ASCII-restrict or ASCII-safe, provides protection for applications that do not need to be exposed to all of Unicode and possible security issues with Unicode.
/a causes the sequences
\w, and the Posix character classes to match only in the ASCII range. Meaning:
\dmeans the digits
my $ascii_letters =~ m/[A-Z]*/i; # not ok my $ascii_letters =~ m/[A-Z]*/a; # ok my $ascii_letters =~ m/[A-Z]*/aa; # ok
\smeans the five characters
[ \f\n\r\t], and starting in Perl v5.18, also the vertical tab
my $characters =~ m/[ \f\n\r\t]*/; # not ok my $characters =~ m/[ \f\n\r\t]*/a; # ok my $characters =~ m/[ \f\n\r\t]*/aa; # ok
\wmeans the 63 characters
[A-Za-z0-9_]and all the Posix classes such as
[[:print:]]match only the appropriate ASCII-range characters
my $letters =~ m/[A-Za-z0-9_]*/; # not ok my $letters =~ m/[A-Za-z0-9_]*/a; # ok my $letters =~ m/[A-Za-z0-9_]*/aa; # ok
The policy also supports the pragma:
use re 'a';
use re 'aa';
Which mean it will not evaluate the regular expressions any further:
use re 'a'; my $letters =~ m/[A-Za-z0-9_]*/; # ok
Do note that the
/aa modifiers require Perl 5.14, so by using the recommended modifiers you indirectly introduct a requirement for Perl 5.14.
This policy is inspired by Perl::Critic::Policy::RegularExpressions::RequireExtendedFormatting and many implementation details was lifted from this particular distribution.
This policy is not configurable at this time. Please see the TODO "section".
This distribution holds no known incompatibilities at this time, please see "DEPENDENCIES AND REQUIREMENTS" for details on version requirements.
The pragma handling does not take into consideration of a pragma is disabled.
The pragma handling does not take lexical scope into consideration properly and only detects the definition once
This distribution holds no other known limitations or bugs at this time, please refer to the the issue listing on GitHub for more up to date information.
Please report bugs via GitHub.
This distribution aims to adhere to the Perl::Critic::Policy standards and Perl best practices and recommendations.
This distribution requires:
Please see the listing in the file: cpanfile, included with the distribution for a complete listing and description for configuration, test and development.
Ideas and suggestions for improvements and new features are listed in GitHub and are marked as
Please see the issue listing on GitHub
| Perl folk: Looking for a PR challenge task? Check for \d in regexes | that really should be [0-9] or should have the /a regex modifier. | Perl is multinational by default! #TPCiSLC
Perl::Critic::Policy::RegularExpressions::RequireDefault is (C) by jonasbn 2018-2019
Perl::Critic::Policy::RegularExpressions::RequireDefault is released under the Artistic License 2.0
Please see the LICENSE file included with the distribution of this module