mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
raw2att accepts array, but sprintf doesn't
it's not very likely to happen (it did in my case :-) ) but if the value is an array, sprintf will fail (because raw2att accepts array, but sprintf doesn't). i suggest to json encode any array data to ensure it's safely included in the html. Or we should throw proper exceptions to make sure invalid values do not result in a php error.
This commit is contained in:
parent
89df5515ae
commit
fdd5acff5d
@ -730,7 +730,11 @@ class FormField extends RequestHandler
|
||||
if ($value === true) {
|
||||
$parts[] = sprintf('%s="%s"', $name, $name);
|
||||
} else {
|
||||
$parts[] = sprintf('%s="%s"', $name, Convert::raw2att($value));
|
||||
$strValue = Convert::raw2att($value);
|
||||
if (!is_string($strValue)) {
|
||||
$strValue = json_encode($strValue);
|
||||
}
|
||||
$parts[] = sprintf('%s="%s"', $name, $strValue);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user