Revision 8916d7ec
Added by Assos Assos over 4 years ago
drupal7/sites/all/modules/webform_validation/modules/webform_validation_testing/webform_validation_testing.features.inc | ||
---|---|---|
1 |
<?php |
|
2 |
|
|
3 |
/** |
|
4 |
* @file |
|
5 |
* webform_validation_testing.features.inc |
|
6 |
*/ |
|
7 |
|
|
8 |
/** |
|
9 |
* Implements hook_node_info(). |
|
10 |
*/ |
|
11 |
function webform_validation_testing_node_info() { |
|
12 |
$items = array( |
|
13 |
'webform' => array( |
|
14 |
'name' => t('Webform'), |
|
15 |
'base' => 'node_content', |
|
16 |
'description' => t('Create a new form or questionnaire accessible to users. Submission results and statistics are recorded and accessible to privileged users.'), |
|
17 |
'has_title' => '1', |
|
18 |
'title_label' => t('Title'), |
|
19 |
'help' => '', |
|
20 |
), |
|
21 |
); |
|
22 |
drupal_alter('node_info', $items); |
|
23 |
return $items; |
|
24 |
} |
drupal7/sites/all/modules/webform_validation/modules/webform_validation_testing/webform_validation_testing.features.uuid_node.inc | ||
---|---|---|
1 |
<?php |
|
2 |
|
|
3 |
/** |
|
4 |
* @file |
|
5 |
* webform_validation_testing.features.uuid_node.inc |
|
6 |
*/ |
|
7 |
|
|
8 |
/** |
|
9 |
* Implements hook_uuid_features_default_content(). |
|
10 |
*/ |
|
11 |
function webform_validation_testing_uuid_features_default_content() { |
|
12 |
$nodes = array(); |
|
13 |
|
|
14 |
$nodes[] = array( |
|
15 |
'title' => 'webform_validation uuid_features test', |
|
16 |
'log' => '', |
|
17 |
'status' => 1, |
|
18 |
'comment' => 0, |
|
19 |
'promote' => 1, |
|
20 |
'sticky' => 0, |
|
21 |
'type' => 'webform', |
|
22 |
'language' => 'und', |
|
23 |
'created' => 1504429473, |
|
24 |
'tnid' => 0, |
|
25 |
'translate' => 0, |
|
26 |
'uuid' => '4ca52408-9bbd-49fa-baae-698c37dc5f42', |
|
27 |
'webform' => array( |
|
28 |
'nid' => 1, |
|
29 |
'next_serial' => 1, |
|
30 |
'confirmation' => '', |
|
31 |
'confirmation_format' => NULL, |
|
32 |
'redirect_url' => '<confirmation>', |
|
33 |
'status' => 1, |
|
34 |
'block' => 0, |
|
35 |
'allow_draft' => 0, |
|
36 |
'auto_save' => 0, |
|
37 |
'submit_notice' => 1, |
|
38 |
'confidential' => 0, |
|
39 |
'submit_text' => '', |
|
40 |
'submit_limit' => -1, |
|
41 |
'submit_interval' => -1, |
|
42 |
'total_submit_limit' => -1, |
|
43 |
'total_submit_interval' => -1, |
|
44 |
'progressbar_bar' => 1, |
|
45 |
'progressbar_page_number' => 0, |
|
46 |
'progressbar_percent' => 0, |
|
47 |
'progressbar_pagebreak_labels' => 1, |
|
48 |
'progressbar_include_confirmation' => 1, |
|
49 |
'progressbar_label_first' => 'Start', |
|
50 |
'progressbar_label_confirmation' => 'Complete', |
|
51 |
'preview' => 0, |
|
52 |
'preview_next_button_label' => '', |
|
53 |
'preview_prev_button_label' => '', |
|
54 |
'preview_title' => '', |
|
55 |
'preview_message' => '', |
|
56 |
'preview_message_format' => NULL, |
|
57 |
'preview_excluded_components' => array(), |
|
58 |
'record_exists' => TRUE, |
|
59 |
'roles' => array( |
|
60 |
0 => 1, |
|
61 |
1 => 2, |
|
62 |
), |
|
63 |
'emails' => array(), |
|
64 |
'components' => array( |
|
65 |
1 => array( |
|
66 |
'nid' => 1, |
|
67 |
'cid' => 1, |
|
68 |
'pid' => 0, |
|
69 |
'form_key' => 'answer', |
|
70 |
'name' => 'What’s the answer to the ultimate question?', |
|
71 |
'type' => 'number', |
|
72 |
'value' => '', |
|
73 |
'extra' => array( |
|
74 |
'title_display' => 'before', |
|
75 |
'description_above' => 0, |
|
76 |
'private' => 0, |
|
77 |
'wrapper_classes' => '', |
|
78 |
'css_classes' => '', |
|
79 |
'integer' => 1, |
|
80 |
'type' => 'textfield', |
|
81 |
'field_prefix' => '', |
|
82 |
'field_suffix' => '', |
|
83 |
'disabled' => 0, |
|
84 |
'unique' => 0, |
|
85 |
'description' => '', |
|
86 |
'attributes' => array(), |
|
87 |
'analysis' => FALSE, |
|
88 |
'min' => '', |
|
89 |
'max' => '', |
|
90 |
'step' => '', |
|
91 |
'decimals' => '', |
|
92 |
'point' => '.', |
|
93 |
'separator' => ',', |
|
94 |
'excludezero' => 0, |
|
95 |
), |
|
96 |
'required' => 1, |
|
97 |
'weight' => 0, |
|
98 |
'page_num' => 1, |
|
99 |
), |
|
100 |
), |
|
101 |
'conditionals' => array(), |
|
102 |
'validation' => array( |
|
103 |
'answer_42' => array( |
|
104 |
'rulename' => 'answer_42', |
|
105 |
'validator' => 'specific_value', |
|
106 |
'data' => 42, |
|
107 |
'error_message' => 'That’s the wrong answer.', |
|
108 |
'negate' => FALSE, |
|
109 |
'weight' => 0, |
|
110 |
'components' => array( |
|
111 |
1 => 1, |
|
112 |
), |
|
113 |
), |
|
114 |
), |
|
115 |
), |
|
116 |
'date' => '2017-09-03 09:04:33 +0000', |
|
117 |
'user_uuid' => '155c7ec5-8f9d-4934-888d-6951b7ac0728', |
|
118 |
); |
|
119 |
return $nodes; |
|
120 |
} |
drupal7/sites/all/modules/webform_validation/modules/webform_validation_testing/webform_validation_testing.info | ||
---|---|---|
2 | 2 |
description = Helps with testing Webform Validation module. |
3 | 3 |
core = 7.x |
4 | 4 |
package = Testing |
5 |
dependencies[] = features |
|
6 |
dependencies[] = node |
|
7 |
dependencies[] = uuid_features |
|
8 | 5 |
dependencies[] = webform_validation |
9 | 6 |
hidden = TRUE |
10 |
features[features_api][] = api:2 |
|
11 |
features[node][] = webform |
|
12 |
features[uuid_node][] = 4ca52408-9bbd-49fa-baae-698c37dc5f42 |
|
13 | 7 |
|
14 |
; Information added by Drupal.org packaging script on 2019-08-26
|
|
15 |
version = "7.x-1.16"
|
|
8 |
; Information added by Drupal.org packaging script on 2020-01-17
|
|
9 |
version = "7.x-1.17"
|
|
16 | 10 |
core = "7.x" |
17 | 11 |
project = "webform_validation" |
18 |
datestamp = "1566849187" |
|
12 |
datestamp = "1579281188" |
drupal7/sites/all/modules/webform_validation/modules/webform_validation_testing/webform_validation_testing.module | ||
---|---|---|
5 | 5 |
* Module file for webform_validation_testing. |
6 | 6 |
*/ |
7 | 7 |
|
8 |
include_once 'webform_validation_testing.features.inc'; |
|
9 |
|
|
10 | 8 |
/** |
11 | 9 |
* Implements hook_webform_validation_validators(). |
12 | 10 |
*/ |
drupal7/sites/all/modules/webform_validation/tests/WebformValidationUnitTestCase.test | ||
---|---|---|
16 | 16 |
); |
17 | 17 |
} |
18 | 18 |
|
19 |
/** |
|
20 |
* {@inheritdoc} |
|
21 |
*/ |
|
22 |
public function setUp() { |
|
23 |
parent::setUp(); |
|
24 |
} |
|
25 |
|
|
26 | 19 |
/** |
27 | 20 |
* The tests. |
28 | 21 |
*/ |
29 | 22 |
public function test() { |
23 |
require_once __DIR__ . '/../webform_validation.validators.inc'; |
|
30 | 24 |
|
31 | 25 |
$validator_name = 'comparison'; |
32 | 26 |
$items = array( |
... | ... | |
62 | 56 |
$test_value = webform_validation_webform_validation_validate($validator_name, $items, $components, $rule); |
63 | 57 |
$value = array('two' => 'Error message.'); |
64 | 58 |
$this->assertIdentical($test_value, $value, 'Error for failing validation.'); |
59 |
|
|
60 |
// Test the 'pattern' validator. |
|
61 |
$validator_name = 'pattern'; |
|
62 |
$items = []; |
|
63 |
$components = []; |
|
64 |
$rule = [ |
|
65 |
'data' => 'D-25##|(###) ###-####|@# #@@|@## #@@|@@# #@@|@@## #@@|@#@ #@@|@@#@ #@@|GIR0AA', |
|
66 |
'error_message' => 'Invalid value.', |
|
67 |
]; |
|
68 |
|
|
69 |
$items['item_1'] = 'D-25AA'; |
|
70 |
$test = webform_validation_webform_validation_validate($validator_name, $items, $components, $rule); |
|
71 |
$this->assertIdentical(count($test), 1, $items['item_1'] . ' fails validation.'); |
|
72 |
|
|
73 |
$items['item_1'] = 'D-2500'; |
|
74 |
$test = webform_validation_webform_validation_validate($validator_name, $items, $components, $rule); |
|
75 |
$this->assertIdentical(count($test), 0, $items['item_1'] . ' passes validation.'); |
|
76 |
|
|
77 |
$items['item_1'] = '(123)-456-7890'; |
|
78 |
$test = webform_validation_webform_validation_validate($validator_name, $items, $components, $rule); |
|
79 |
$this->assertIdentical(count($test), 1, $items['item_1'] . ' fails validation.'); |
|
80 |
|
|
81 |
$items['item_1'] = '(123) 456-7890'; |
|
82 |
$test = webform_validation_webform_validation_validate($validator_name, $items, $components, $rule); |
|
83 |
$this->assertIdentical(count($test), 0, $items['item_1'] . ' passes validation.'); |
|
65 | 84 |
} |
66 | 85 |
|
67 | 86 |
} |
drupal7/sites/all/modules/webform_validation/tests/WebformValidationUuidFeaturesTestCase.test | ||
---|---|---|
1 |
<?php |
|
2 |
|
|
3 |
/** |
|
4 |
* Test the features integration of webform_validation. |
|
5 |
*/ |
|
6 |
class WebformValidationUuidFeaturesTestCase extends DrupalWebTestCase { |
|
7 |
|
|
8 |
/** |
|
9 |
* {@inheritdoc} |
|
10 |
*/ |
|
11 |
public static function getInfo() { |
|
12 |
return array( |
|
13 |
'name' => t('Webform Validation: UUID features integration'), |
|
14 |
'description' => t('Test the integration of webform_validation and uuid_features.'), |
|
15 |
'group' => t('Webform'), |
|
16 |
'dependencies' => array('webform_validation_testing'), |
|
17 |
); |
|
18 |
} |
|
19 |
|
|
20 |
/** |
|
21 |
* {@inheritdoc} |
|
22 |
*/ |
|
23 |
public function setUp() { |
|
24 |
parent::setUp(array('webform_validation_testing')); |
|
25 |
module_load_include('entity.inc', 'uuid'); |
|
26 |
} |
|
27 |
|
|
28 |
/** |
|
29 |
* Test whether the validations are loaded properly by enabling the feature. |
|
30 |
*/ |
|
31 |
public function testValidationsLoaded() { |
|
32 |
$uuids = array('4ca52408-9bbd-49fa-baae-698c37dc5f42'); |
|
33 |
$nids = entity_get_id_by_uuid('node', $uuids); |
|
34 |
$nid = reset($nids); |
|
35 |
$rules = webform_validation_get_node_rules($nid); |
|
36 |
$this->assertEqual(1, count($rules)); |
|
37 |
$rule = reset($rules); |
|
38 |
unset($rule['ruleid']); |
|
39 |
unset($rule['nid']); |
|
40 |
$k = array_keys($rule['components']); |
|
41 |
$rule['components'] = array_combine($k, $k); |
|
42 |
$this->assertEqual(array( |
|
43 |
'rulename' => 'answer_42', |
|
44 |
'validator' => 'specific_value', |
|
45 |
'data' => '42', |
|
46 |
'error_message' => 'That’s the wrong answer.', |
|
47 |
'negate' => FALSE, |
|
48 |
'weight' => '0', |
|
49 |
'components' => array( |
|
50 |
1 => 1, |
|
51 |
), |
|
52 |
), $rule); |
|
53 |
} |
|
54 |
|
|
55 |
/** |
|
56 |
* Test whether re-exporting the feature yields the same result. |
|
57 |
*/ |
|
58 |
public function testValidationExport() { |
|
59 |
features_include_defaults(); |
|
60 |
|
|
61 |
// Get data for a new export. |
|
62 |
$uuids = array('4ca52408-9bbd-49fa-baae-698c37dc5f42'); |
|
63 |
$data = features_invoke('uuid_node', 'features_export_render', 'webform_validation_uuid_features_test', $uuids); |
|
64 |
$nodes = eval($data['uuid_features_default_content']); |
|
65 |
$this->assertEqual(1, count($nodes)); |
|
66 |
$node = (object) reset($nodes); |
|
67 |
$this->assertEqual($uuids[0], $node->uuid); |
|
68 |
$this->assertTrue(!empty($node->webform['validation'])); |
|
69 |
|
|
70 |
// Compare data with the defaults in the feature. |
|
71 |
$defaults = features_get_default('uuid_node', 'webform_validation_testing'); |
|
72 |
$default_node = (object) reset($defaults); |
|
73 |
$this->assertEqual($default_node->webform['validation'], $node->webform['validation']); |
|
74 |
} |
|
75 |
|
|
76 |
} |
drupal7/sites/all/modules/webform_validation/webform_validation.info | ||
---|---|---|
3 | 3 |
core = 7.x |
4 | 4 |
package = Webform |
5 | 5 |
dependencies[] = webform |
6 |
test_dependencies[] = webform_validation_testing
|
|
6 |
test_dependencies[] = token
|
|
7 | 7 |
files[] = tests/WebformValidationTestCase.test |
8 | 8 |
files[] = tests/WebformValidationUnitTestCase.test |
9 |
files[] = tests/WebformValidationUuidFeaturesTestCase.test |
|
10 | 9 |
php = 5.3 |
11 | 10 |
|
12 |
; Information added by Drupal.org packaging script on 2019-08-26
|
|
13 |
version = "7.x-1.16"
|
|
11 |
; Information added by Drupal.org packaging script on 2020-01-17
|
|
12 |
version = "7.x-1.17"
|
|
14 | 13 |
core = "7.x" |
15 | 14 |
project = "webform_validation" |
16 |
datestamp = "1566849187" |
|
15 |
datestamp = "1579281188" |
drupal7/sites/all/modules/webform_validation/webform_validation.module | ||
---|---|---|
191 | 191 |
} |
192 | 192 |
$rule['sid'] = $sid; |
193 | 193 |
// Have the submitted values validated. |
194 |
$errors = module_invoke_all("webform_validation_validate", $rule['validator'], webform_validation_prefix_keys($items), webform_validation_prefix_keys($node->webform['components']), $rule); |
|
194 |
$components = webform_validation_prefix_keys($node->webform['components']); |
|
195 |
// Allow translation for all components item names if available. |
|
196 |
if (module_exists('webform_localization')) { |
|
197 |
module_load_include('inc', 'webform_localization', 'includes/webform_localization.i18n'); |
|
198 |
foreach ($components as &$component) { |
|
199 |
$dummy_element = array( |
|
200 |
'#title' => '', |
|
201 |
); |
|
202 |
_webform_localization_translate_component($dummy_element, $component); |
|
203 |
if (isset($dummy_element['#title']) && (string) $dummy_element['#title']) { |
|
204 |
$component['name'] = $dummy_element['#title']; |
|
205 |
} |
|
206 |
} |
|
207 |
} |
|
208 |
|
|
209 |
$errors = module_invoke_all("webform_validation_validate", $rule['validator'], webform_validation_prefix_keys($items), $components, $rule); |
|
195 | 210 |
if ($errors) { |
196 | 211 |
$errors = webform_validation_unprefix_keys($errors); |
197 | 212 |
// Create hook_webform_validation_validate_alter(). Allow other modules |
... | ... | |
540 | 555 |
* Implements hook_uuid_node_features_export_alter(). |
541 | 556 |
*/ |
542 | 557 |
function webform_validation_uuid_node_features_export_alter(&$data, $node, $module) { |
543 |
$nid = reset(entity_get_id_by_uuid('node', array($node->uuid))); |
|
558 |
$nid = entity_get_id_by_uuid('node', array($node->uuid)); |
|
559 |
$nid = reset($nid); |
|
544 | 560 |
if (webform_validation_get_node_rules($nid)) { |
545 | 561 |
$data['dependencies']['webform_validation'] = 'webform_validation'; |
546 | 562 |
} |
drupal7/sites/all/modules/webform_validation/webform_validation.validators.inc | ||
---|---|---|
123 | 123 |
), |
124 | 124 |
'custom_data' => array( |
125 | 125 |
'label' => t('Number the fields add up to'), |
126 |
'description' => t('Specify the number and the type of comparison. For example:') . theme('item_list', array( |
|
127 |
'items' => array( |
|
128 |
t('Enter "=3" if the components must add up to exactly 3.'), |
|
129 |
t('Enter ">10" if the components must add up to greater than 10.'), |
|
130 |
t('Enter ">=10" if the components must add up to greater than or equal to 10.'), |
|
131 |
t('Enter "<20" if the components must add up to less than 20.'), |
|
132 |
t('Enter "<=20" if the components must add up to less than or equal to 20.'), |
|
126 |
'description' => t('Specify the number and the type of comparison. For example:') . theme('table', array( |
|
127 |
'header' => array(t('Value'), t('Meaning')), |
|
128 |
'rows' => array( |
|
129 |
array('=3', t('The components must add up to exactly 3.')), |
|
130 |
array('>10', t('The components must add up to greater than 10.')), |
|
131 |
array('>=10', t('The components must add up to greater than or equal to 10.')), |
|
132 |
array('<20', t('The components must add up to less than 20.')), |
|
133 |
array('<=20', t('The components must add up to less than or equal to 20.')), |
|
133 | 134 |
), |
134 | 135 |
)), |
135 | 136 |
'validate_regex' => '/^(=|>|>=|<|<=)(-?[\d.]+)$/', |
... | ... | |
239 | 240 |
), |
240 | 241 |
'custom_data' => array( |
241 | 242 |
'label' => t('Number to be completed'), |
242 |
'description' => t('Specify the number that must be completed and the type of comparison. For example:') . theme('item_list', array( |
|
243 |
'items' => array( |
|
244 |
t('Enter ">=1" if the user must complete <b>at least</b> 1 of the selected components.'), |
|
245 |
t('Enter "=3" if the user must complete <b>exactly</b> 3 of the selected components.'), |
|
246 |
t('Enter "<=2" if the user must complete <b>at most</b> 2 of the selected components.'), |
|
243 |
'description' => t('Specify the number that must be completed and the type of comparison. For example:') . theme('table', array( |
|
244 |
'header' => array(t('Value'), t('Meaning')), |
|
245 |
'rows' => array( |
|
246 |
array('>=1', t('The user must complete <b>at least</b> 1 of the selected components.')), |
|
247 |
array('=3', t('The user must complete <b>exactly</b> 3 of the selected components.')), |
|
248 |
array('<=2', t('The user must complete <b>at most</b> 2 of the selected components.')), |
|
247 | 249 |
), |
248 | 250 |
)), |
249 | 251 |
'validate_regex' => '/^[><]?=\d+$/', |
... | ... | |
341 | 343 |
'custom_error' => TRUE, |
342 | 344 |
'custom_data' => array( |
343 | 345 |
'label' => t('Pattern'), |
344 |
'description' => t('Specify a pattern where:') . theme('item_list', array('items' => array(t('@ = any letter A-Z'), t('# = any numeral 0-9'), t('| = separates two or more acceptable patterns'), t('Any other character must appear in its exact position')))) . t('Examples') . theme('item_list', array('items' => array(t('North American phone number: (###) ###-####'), t('D-2500 series model numbers: D-25##'), t('UK Postal Code: @# #@@|@## #@@|@@# #@@|@@## #@@|@#@ #@@|@@#@ #@@|GIR0AA')))), |
|
346 |
'description' => t('Specify a pattern where:') . theme('table', array( |
|
347 |
'header' => array(t('Value'), t('Meaning')), |
|
348 |
'rows' => array( |
|
349 |
array('@', t('Any letter A-Z.')), |
|
350 |
array('#', t('Any numeral 0-9.')), |
|
351 |
array('|', t('Separates two or more acceptable patterns.')), |
|
352 |
array('', t('Any other character must appear in its exact position.')), |
|
353 |
), |
|
354 |
)) . t('Examples:') . theme('table', array( |
|
355 |
'header' => array(t('Value'), t('Meaning')), |
|
356 |
'rows' => array( |
|
357 |
array('(###) ###-####', t('North American phone number.')), |
|
358 |
array('D-25##', t('D-2500 series model numbers.')), |
|
359 |
array('@# #@@|@## #@@|@@# #@@|@@## #@@|@#@ #@@|@@#@ #@@|GIR0AA', t('UK Postal Code.')), |
|
360 |
), |
|
361 |
)), |
|
345 | 362 |
), |
346 | 363 |
'description' => t('Verifies that a user-entered value follows to a specified pattern.'), |
347 | 364 |
), |
... | ... | |
452 | 469 |
return NULL; |
453 | 470 |
} |
454 | 471 |
|
455 |
// Allow translation for all components item names if available. |
|
456 |
if (module_exists('webform_localization')) { |
|
457 |
foreach ($components as &$component) { |
|
458 |
$dummy_element = array( |
|
459 |
'#title' => '', |
|
460 |
); |
|
461 |
_webform_localization_translate_component($dummy_element, $component); |
|
462 |
if (isset($dummy_element['#title']) && (string) $dummy_element['#title']) { |
|
463 |
$component['name'] = $dummy_element['#title']; |
|
464 |
} |
|
465 |
} |
|
466 |
} |
|
467 |
|
|
468 | 472 |
// For certain validators, if all components to be compared are email |
469 | 473 |
// components, make the values lower-case to avoid case-sensitive comparison. |
470 | 474 |
if (in_array($validator_name, array('equal', 'comparison', 'unique'))) { |
... | ... | |
516 | 520 |
if (isset($num_range['min']) && isset($num_range['max'])) { |
517 | 521 |
// Validate the min - max range. |
518 | 522 |
if ($subval < $num_range['min'] || $subval > $num_range['max']) { |
519 |
$errors[$key] = t('%item is not within the allowed range %range.', array('%item' => $components[$key]['name'], '%range' => str_replace('|', ' - ', $rule['data']))); |
|
523 |
$options = array( |
|
524 |
'%item' => $components[$key]['name'], |
|
525 |
'%range' => str_replace('|', ' - ', $rule['data']), |
|
526 |
); |
|
527 |
$errors[$key] = t('%item is not within the allowed range %range.', $options); |
|
520 | 528 |
} |
521 | 529 |
} |
522 | 530 |
else { |
... | ... | |
859 | 867 |
'regular' => '%item must %verb with "%string".', |
860 | 868 |
'negated' => '%item must not %verb with "%string".', |
861 | 869 |
); |
862 |
$error_vars = array('%item' => $components[$key]['name'], '%verb' => $verb, '%string' => $rule['data']); |
|
870 |
$error_vars = array( |
|
871 |
'%item' => $components[$key]['name'], |
|
872 |
'%verb' => $verb, |
|
873 |
'%string' => $rule['data'], |
|
874 |
); |
|
863 | 875 |
foreach ($val as $subval) { |
864 | 876 |
$test = !preg_match($pattern, $subval); |
865 | 877 |
_webform_validation_test($errors, $key, $rule, $test, $error_strings, $error_vars); |
... | ... | |
870 | 882 |
case 'pattern': |
871 | 883 |
$pattern = preg_quote($rule['data'], '/'); |
872 | 884 |
$pattern = str_replace('@', '[a-zA-Z]', $pattern); |
873 |
$pattern = str_replace('#', '[0-9]', $pattern); |
|
885 |
// Since PHP 7.3, the # character is quoted by preg_quote(). |
|
886 |
$quoted_hash = version_compare(PHP_VERSION, '7.3.0', '>=') ? '\\#' : '#'; |
|
887 |
$pattern = str_replace($quoted_hash, '[0-9]', $pattern); |
|
874 | 888 |
$pattern = '(' . $pattern . ')'; |
875 | 889 |
// Un-escape "|" operator. |
876 | 890 |
$pattern = preg_replace('/(\\s*)(\\\\)(\\|)(\\s*)/', ')|(', $pattern); |
... | ... | |
909 | 923 |
return $errors; |
910 | 924 |
|
911 | 925 |
case 'blacklist': |
912 |
$blacklist = preg_quote($rule['data'], '/'); |
|
926 |
$blacklist = $rule['data']; |
|
927 |
$blacklist = token_replace($blacklist); |
|
928 |
$blacklist = preg_quote($blacklist, '/'); |
|
913 | 929 |
$blacklist = explode(',', $blacklist); |
914 | 930 |
$blacklist = array_map('trim', $blacklist); |
915 | 931 |
$blacklist = '/\b(' . implode('|', $blacklist) . ')\b/i'; |
... | ... | |
1120 | 1136 |
function _webform_validation_i18n_error_message($rule) { |
1121 | 1137 |
$rule['error_message'] = filter_xss($rule['error_message']); |
1122 | 1138 |
if (module_exists('i18n')) { |
1139 |
$rule['ruleid'] = isset($rule['ruleid']) ? $rule['ruleid'] : NULL; |
|
1123 | 1140 |
return i18n_string('webform_validation:error_message:' . $rule['ruleid'] . ':message', $rule['error_message']); |
1124 | 1141 |
} |
1125 | 1142 |
return $rule['error_message']; |
Also available in: Unified diff
Weekly update of contrib modules