Skip to content
This repository has been archived by the owner on May 19, 2020. It is now read-only.

Error when updating custom field #1202

Open
shimshinatti opened this issue May 29, 2017 · 3 comments
Open

Error when updating custom field #1202

shimshinatti opened this issue May 29, 2017 · 3 comments

Comments

@shimshinatti
Copy link

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
@TheBrenny
Copy link
Member

Cheers for this one!! How has your solution worried? If it's good enough, maybe send through a PR! :D

@shimshinatti
Copy link
Author

It seems to be working fine. It just follows the logic behind adding custom fields.

@evansharp
Copy link
Contributor

@shimshinatti, you should do a PR for this fix.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants