Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Additional HrefTransform validation for $type and $id #434

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Upgrade Notes

## 5.0.4
- Add Additional HrefTransformer validation for `$type` and `$id` [patkul0](https://github.com/dachcom-digital/pimcore-formbuilder/pull/434)

## 5.0.3
- Fix element type check in api channel [#423](https://github.com/dachcom-digital/pimcore-formbuilder/issues/423)

Expand Down
6 changes: 5 additions & 1 deletion src/Transformer/HrefTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,12 @@ public function reverseTransform(mixed $values, $optionConfig = null): array
$type = $value['type'];
$id = $value['id'];

if (empty($id) || !in_array($type, ['object', 'asset', 'document'])) {
continue;
}

if (is_numeric($id)) {
$element = Service::getElementById($type, $id);
$element = Service::getElementById($type, (int) $id);
} else {
// legacy
$element = Service::getElementByPath($type, $id);
Expand Down
Loading