Error when updating custom field
Opened this issue · 3 comments
When updating a custom field, an error occurs which says
Whoops!
Something wrong happened.
I checked the code for editing a custom field and found where the problem was.
The code is located at: \anchor\routes\fields.php
on lines 135-137
.
foreach($input as $key => &$value) {
$value = eq($value);
}
It seems to be missing an if
statement that can be found in the same identical code on lines 44-50
, for adding custom fields.
// an array of items that we shouldn't encode - they're no XSS threat
$dont_encode = array('attributes');
foreach($input as $key => &$value) {
if(in_array($key, $dont_encode)) continue;
$value = eq($value);
}
The if
statement basically excludes the attributes
index because it is an Array
. Because this statement is missing for the editing of custom fields (lines 135-137
), the attributes
array gets passed onto the eq()
method. This method just calls htmlspecialchars()
, which only accepts a string
value for its 1st parameter.
Now for the solution, I just copied the code found on lines 44-50
and replaced the code found on lines 135-137
.
- Anchor version: 0.12.1
Cheers for this one!! How has your solution worried? If it's good enough, maybe send through a PR! :D
It seems to be working fine. It just follows the logic behind adding custom fields.
@shimshinatti, you should do a PR for this fix.