PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 3.1.6
JetFormBuilder — Dynamic Blocks Form Builder v3.1.6
3.6.3.1 3.6.3 3.6.2.2 3.6.2.1 3.6.2 3.6.1.1 3.6.1 3.6.0.1 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.1.0 2.1.1 2.1.10 2.1.11 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 3.0.0 3.0.0.1 3.0.0.2 3.0.0.3 3.0.1 3.0.1.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.0.1 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0 3.2.1 3.2.2 3.2.3 3.3.0 3.3.1 3.3.2 3.3.3 3.3.3.1 3.3.4 3.3.4.1 3.3.4.2 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.5.1 3.4.5.2 3.4.6 3.4.7 3.4.7.1 3.5.0 3.5.1 3.5.1.1 3.5.1.2 3.5.2 3.5.2.1 3.5.3 3.5.4 3.5.5 3.5.6 3.5.6.1 3.5.6.2 3.5.6.3 3.6.0
jetformbuilder / includes / blocks / ssr-validation / validation-callbacks.php
jetformbuilder / includes / blocks / ssr-validation Last commit date
base-validation-callback.php 2 years ago is-user-email-unique.php 2 years ago is-user-login-unique.php 2 years ago rest-controller.php 2 years ago rest-validation-endpoint.php 2 years ago validation-callbacks.php 2 years ago
validation-callbacks.php
89 lines
1 <?php
2
3
4 namespace Jet_Form_Builder\Blocks\Ssr_Validation;
5
6 use JFB_Components\Repository\Repository_Pattern_Trait;
7 use Jet_Form_Builder\Exceptions\Repository_Exception;
8 use JFB_Modules\Block_Parsers\Field_Data_Parser;
9
10 // If this file is called directly, abort.
11 if ( ! defined( 'WPINC' ) ) {
12 die;
13 }
14
15 class Validation_Callbacks {
16
17 use Repository_Pattern_Trait;
18
19 const NOT_ALLOWED = array(
20 'var_dump',
21 'var_export',
22 'print_r',
23 'sprintf',
24 'printf',
25 'shell_exec',
26 'system',
27 'exec',
28 'unserialize',
29 'file_get_contents',
30 'maybe_unserialize',
31 );
32
33 public function __construct() {
34 $this->rep_install();
35 }
36
37 public function rep_instances(): array {
38 return apply_filters(
39 'jet-form-builder/validation-callbacks',
40 array(
41 new Is_User_Login_Unique(),
42 new Is_User_Email_Unique(),
43 )
44 );
45 }
46
47 /**
48 * @return Base_Validation_Callback[]
49 */
50 public function get_items(): array {
51 return $this->rep_get_items();
52 }
53
54
55 public function validate( Field_Data_Parser $parser, string $function_name ): bool {
56 try {
57 /** @var Base_Validation_Callback $callback */
58 $callback = $this->rep_get_item( $function_name );
59 } catch ( Repository_Exception $exception ) {
60 return $this->validate_custom( $parser, $function_name );
61 }
62
63 return $callback->is_valid( $parser->get_value(), $parser->get_context() );
64 }
65
66 protected function validate_custom( Field_Data_Parser $parser, string $function_name ): bool {
67 $name = $this->validate_callback( $function_name );
68
69 if ( ! $name ) {
70 return false;
71 }
72
73 return (bool) call_user_func( $name, $parser->get_value(), $parser->get_context() );
74 }
75
76 protected function validate_callback( string $function_name ): string {
77 $name = preg_replace( '/[^\w]/i', '', $function_name );
78
79 if ( $name !== $function_name ||
80 // not in the blacklist
81 in_array( $name, self::NOT_ALLOWED, true )
82 ) {
83 return '';
84 }
85
86 return function_exists( $name ) ? $name : '';
87 }
88 }
89