Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
justinfreeman (Agileware)
Core
Commits
c61683d9
Commit
c61683d9
authored
11 years ago
by
Tim Otten
Browse files
Options
Downloads
Plain Diff
Merge pull request #749 from eileenmcnaughton/test-fix
CRM-12626 Fix test by no validating arrays passed into string fields
parents
e349d817
69c1fac4
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
api/v3/utils.php
+10
-2
10 additions, 2 deletions
api/v3/utils.php
with
10 additions
and
2 deletions
api/v3/utils.php
+
10
−
2
View file @
c61683d9
...
...
@@ -1516,7 +1516,15 @@ function _civicrm_api3_validate_html(&$params, &$fieldname, &$fieldInfo) {
*/
function
_civicrm_api3_validate_string
(
&
$params
,
&
$fieldname
,
&
$fieldInfo
)
{
// If fieldname exists in params
$value
=
(
string
)
CRM_Utils_Array
::
value
(
$fieldname
,
$params
,
''
);
$value
=
CRM_Utils_Array
::
value
(
$fieldname
,
$params
,
''
);
if
(
!
is_array
(
$value
)){
$value
=
(
string
)
$value
;
}
else
{
//@todo what do we do about passed in arrays. For many of these fields
// the missing piece of functionality is separating them to a separated string
// & many save incorrectly. But can we change them wholesale?
}
if
(
$value
)
{
if
(
!
CRM_Utils_Rule
::
xssString
(
$value
))
{
throw
new
Exception
(
'Illegal characters in input (potential scripting attack)'
);
...
...
@@ -1532,7 +1540,7 @@ function _civicrm_api3_validate_string(&$params, &$fieldname, &$fieldInfo) {
$lowerCaseOptions
=
array_map
(
"strtolower"
,
$options
);
// If value passed is not a key, it may be a label
// Try to lookup key from label - if it can't be found throw error
if
(
!
isset
(
$options
[
strtolower
(
$value
)])
&&
!
isset
(
$options
[
$value
])
)
{
if
(
!
is_array
(
$value
)
&&
!
isset
(
$options
[
strtolower
(
$value
)])
&&
!
isset
(
$options
[
$value
])
)
{
if
(
!
in_array
(
strtolower
(
$value
),
$lowerCaseOptions
))
{
throw
new
Exception
(
"
$fieldname
`
$value
` is not valid."
);
}
...
...
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