Skip to content

Commit

Permalink
Update MFormParser.php to esacpe values with single & double quotes
Browse files Browse the repository at this point in the history
Added `htmlspecialchars(json_encode($itemValue), ENT_QUOTES, 'UTF-8')` to support or rather esacpe values containing single and/or double quotes.
  • Loading branch information
ynamite authored and skerbis committed Sep 17, 2024
1 parent 564941a commit c5136f0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/MForm/Parser/MFormParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ private function openRepeaterElement(MFormItem $item, string $key, array $items)
$confirm .= (isset($item->getAttributes()['confirm_delete_msg'])) ? ', \''.$item->getAttributes()['confirm_delete_msg'] .'\'' : ', \''.rex_i18n::msg('mform_repeater_remove_group_confirm_msg').'\'';
$addInitGroup = ($open) ? ' if('.$groups.'.length <= 0) { addGroup('.$obj.') };' : '';

$output[] = '<section class="repeater" id="'.$repeaterId.'"><div x-data="repeater()" x-repeater @repeater:ready.once=\'setInitialValue('.json_encode($itemValue).');'.$addInitGroup.'\' @selectcustomlink.window="selectCustomLink($event.detail)" id="x-repeater">';
$output[] = '<section class="repeater" id="'.$repeaterId.'"><div x-data="repeater()" x-repeater @repeater:ready.once=\'setInitialValue('.htmlspecialchars(json_encode($itemValue), ENT_QUOTES, 'UTF-8').');'.$addInitGroup.'\' @selectcustomlink.window="selectCustomLink($event.detail)" id="x-repeater">';
// add button
$output[] = '<template x-if="'.$groups.'.length <= 0"><a href="#" type="button" class="btn btn-mform-repeater '.$btnClass.'" @click.prevent=\'addGroup('.$obj.')\'><i class="rex-icon fa-plus-circle"></i> '.((!empty($buttonName))?$buttonName:'Add group').'</a></template>';
$header = '
Expand Down

0 comments on commit c5136f0

Please sign in to comment.