Skip to content

Commit

Permalink
CRM-21707 follow up fix - check keys as well as values for xss if we …
Browse files Browse the repository at this point in the history
…are going to encode json.
  • Loading branch information
eileenmcnaughton committed Jan 25, 2018
1 parent 1678a63 commit 4b02a1c
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions api/v3/utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -2196,15 +2196,13 @@ function _civicrm_api3_validate_string(&$params, &$fieldName, &$fieldInfo, $enti
if (!is_array($fieldValue)) {
$fieldValue = (string) $fieldValue;
}
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 ($fieldValue) {
foreach ((array) $fieldValue as $value) {
if (!CRM_Utils_Rule::xssString($fieldValue)) {
throw new Exception('Input contains illegal SCRIPT tag.');
foreach ((array) $fieldValue as $key => $value) {
foreach ([$fieldValue, $key, $value] as $input) {
if (!CRM_Utils_Rule::xssString($input)) {
throw new Exception('Input contains illegal SCRIPT tag.');
}
}
if ($fieldName == 'currency') {
//When using IN operator $fieldValue is a array of currency codes
Expand Down

0 comments on commit 4b02a1c

Please sign in to comment.