Skip to content

Commit eb9c01b

Browse files
committed
add validation for regex flags
1 parent 05f4ba0 commit eb9c01b

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/DB_Command.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -820,6 +820,10 @@ public function search( $args, $assoc_args ) {
820820

821821
if ( ( $regex = \WP_CLI\Utils\get_flag_value( $assoc_args, 'regex', false ) ) ) {
822822
$regex_flags = \WP_CLI\Utils\get_flag_value( $assoc_args, 'regex-flags', false );
823+
// http://php.net/manual/en/reference.pcre.pattern.modifiers.php
824+
if ( $regex_flags && ! preg_match( '/^(?!.*(.).*\1)[imsxeADSUXJu]+$/', $regex_flags ) ) {
825+
WP_CLI::error( "Incorrect PCRE modifiers." );
826+
}
823827
$regex_delimiter = \WP_CLI\Utils\get_flag_value( $assoc_args, 'regex-delimiter', '/' );
824828
if ( '' === $regex_delimiter ) {
825829
$regex_delimiter = '/';

0 commit comments

Comments
 (0)