Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
drupal
Commits
f639b9e9
Commit
f639b9e9
authored
15 years ago
by
Dries Buytaert
Browse files
Options
Downloads
Patches
Plain Diff
- Patch
#669124
by Arancaytar: list.module incorrectly validated data.
parent
37bacdac
Branches
Branches containing commit
Tags
Tags containing commit
2 merge requests
!7452
Issue #1797438. HTML5 validation is preventing form submit and not fully...
,
!789
Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
modules/field/modules/list/list.module
+2
-2
2 additions, 2 deletions
modules/field/modules/list/list.module
modules/field/modules/list/tests/list.test
+6
-6
6 additions, 6 deletions
modules/field/modules/list/tests/list.test
with
8 additions
and
8 deletions
modules/field/modules/list/list.module
+
2
−
2
View file @
f639b9e9
...
...
@@ -156,8 +156,8 @@ function list_allowed_values_setting_validate($element, &$form_state) {
form_error
(
$element
,
t
(
'Allowed values list: each key must be a valid integer or decimal.'
));
break
;
}
elseif
(
$field_type
==
'list_text'
&&
strlen
(
$key
)
>
255
)
{
form_error
(
$element
,
t
(
'Allowed values list: each key must be a string
less than
255 characters.'
));
elseif
(
$field_type
==
'list_text'
&&
drupal_
strlen
(
$key
)
>
255
)
{
form_error
(
$element
,
t
(
'Allowed values list: each key must be a string
at most
255 characters
long
.'
));
break
;
}
elseif
(
$field_type
==
'list'
&&
!
preg_match
(
'/^-?\d+$/'
,
$key
))
{
...
...
This diff is collapsed.
Click to expand it.
modules/field/modules/list/tests/list.test
+
6
−
6
View file @
f639b9e9
...
...
@@ -139,33 +139,33 @@ class ListFieldUITestCase extends FieldTestCase {
//Check that non-integer keys are rejected.
$edit
=
array
(
$element_name
=>
"1.1|one
\n
"
);
$this
->
drupalPost
(
$admin_path
,
$edit
,
t
(
'Save settings'
));
$this
->
assertText
(
"keys must be integers"
,
t
(
'Form va
i
ldation failed.'
));
$this
->
assertText
(
"keys must be integers"
,
t
(
'Form val
i
dation failed.'
));
// Test 'List (number)' field type.
$admin_path
=
$this
->
createListFieldAndEdit
(
'list_number'
);
//Check that non-numeric keys are rejected.
$edit
=
array
(
$element_name
=>
"1|one
\n
B|two"
);
$this
->
drupalPost
(
$admin_path
,
$edit
,
t
(
'Save settings'
));
$this
->
assertText
(
"each key must be a valid integer or decimal"
,
t
(
'Form va
i
ldation failed.'
));
$this
->
assertText
(
"each key must be a valid integer or decimal"
,
t
(
'Form val
i
dation failed.'
));
//Test 'List (text)' field type.
$admin_path
=
$this
->
createListFieldAndEdit
(
'list_text'
);
//Check that over long keys are rejected.
$edit
=
array
(
$element_name
=>
"1|one
\n
"
.
$this
->
randomName
(
25
5
)
.
"|two"
);
$edit
=
array
(
$element_name
=>
"1|one
\n
"
.
$this
->
randomName
(
25
6
)
.
"|two"
);
$this
->
drupalPost
(
$admin_path
,
$edit
,
t
(
'Save settings'
));
$this
->
assertText
(
"each key must be a string
less than
255 characters"
,
t
(
'Form va
i
ldation failed.'
));
$this
->
assertText
(
"each key must be a string
at most
255 characters
long
"
,
t
(
'Form val
i
dation failed.'
));
// Test 'List (boolean)' field type.
$admin_path
=
$this
->
createListFieldAndEdit
(
'list_boolean'
);
// Check that invalid option keys are rejected.
$edit
=
array
(
$element_name
=>
"1|one
\n
2|two"
);
$this
->
drupalPost
(
$admin_path
,
$edit
,
t
(
'Save settings'
));
$this
->
assertText
(
"keys must be either 0 or 1"
,
t
(
'Form va
i
ldation failed.'
));
$this
->
assertText
(
"keys must be either 0 or 1"
,
t
(
'Form val
i
dation failed.'
));
//Check that missing option causes failure.
$edit
=
array
(
$element_name
=>
"1|one"
);
$this
->
drupalPost
(
$admin_path
,
$edit
,
t
(
'Save settings'
));
$this
->
assertText
(
"two values are required"
,
t
(
'Form va
i
ldation failed.'
));
$this
->
assertText
(
"two values are required"
,
t
(
'Form val
i
dation failed.'
));
}
/**
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment