Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
f639b9e9
Commit
f639b9e9
authored
Dec 29, 2009
by
Dries
Browse files
- Patch
#669124
by Arancaytar: list.module incorrectly validated data.
parent
37bacdac
Changes
2
Hide whitespace changes
Inline
Side-by-side
modules/field/modules/list/list.module
View file @
f639b9e9
...
@@ -156,8 +156,8 @@ function list_allowed_values_setting_validate($element, &$form_state) {
...
@@ -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.'
));
form_error
(
$element
,
t
(
'Allowed values list: each key must be a valid integer or decimal.'
));
break
;
break
;
}
}
elseif
(
$field_type
==
'list_text'
&&
strlen
(
$key
)
>
255
)
{
elseif
(
$field_type
==
'list_text'
&&
drupal_
strlen
(
$key
)
>
255
)
{
form_error
(
$element
,
t
(
'Allowed values list: each key must be a string
less than
255 characters.'
));
form_error
(
$element
,
t
(
'Allowed values list: each key must be a string
at most
255 characters
long
.'
));
break
;
break
;
}
}
elseif
(
$field_type
==
'list'
&&
!
preg_match
(
'/^-?\d+$/'
,
$key
))
{
elseif
(
$field_type
==
'list'
&&
!
preg_match
(
'/^-?\d+$/'
,
$key
))
{
...
...
modules/field/modules/list/tests/list.test
View file @
f639b9e9
...
@@ -139,33 +139,33 @@ class ListFieldUITestCase extends FieldTestCase {
...
@@ -139,33 +139,33 @@ class ListFieldUITestCase extends FieldTestCase {
//Check that non-integer keys are rejected.
//Check that non-integer keys are rejected.
$edit
=
array
(
$element_name
=>
"1.1|one
\n
"
);
$edit
=
array
(
$element_name
=>
"1.1|one
\n
"
);
$this
->
drupalPost
(
$admin_path
,
$edit
,
t
(
'Save settings'
));
$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.
// Test 'List (number)' field type.
$admin_path
=
$this
->
createListFieldAndEdit
(
'list_number'
);
$admin_path
=
$this
->
createListFieldAndEdit
(
'list_number'
);
//Check that non-numeric keys are rejected.
//Check that non-numeric keys are rejected.
$edit
=
array
(
$element_name
=>
"1|one
\n
B|two"
);
$edit
=
array
(
$element_name
=>
"1|one
\n
B|two"
);
$this
->
drupalPost
(
$admin_path
,
$edit
,
t
(
'Save settings'
));
$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.
//Test 'List (text)' field type.
$admin_path
=
$this
->
createListFieldAndEdit
(
'list_text'
);
$admin_path
=
$this
->
createListFieldAndEdit
(
'list_text'
);
//Check that over long keys are rejected.
//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
->
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.
// Test 'List (boolean)' field type.
$admin_path
=
$this
->
createListFieldAndEdit
(
'list_boolean'
);
$admin_path
=
$this
->
createListFieldAndEdit
(
'list_boolean'
);
// Check that invalid option keys are rejected.
// Check that invalid option keys are rejected.
$edit
=
array
(
$element_name
=>
"1|one
\n
2|two"
);
$edit
=
array
(
$element_name
=>
"1|one
\n
2|two"
);
$this
->
drupalPost
(
$admin_path
,
$edit
,
t
(
'Save settings'
));
$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.
//Check that missing option causes failure.
$edit
=
array
(
$element_name
=>
"1|one"
);
$edit
=
array
(
$element_name
=>
"1|one"
);
$this
->
drupalPost
(
$admin_path
,
$edit
,
t
(
'Save settings'
));
$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.'
));
}
}
/**
/**
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment