Skip to content

Commit 1549000

Browse files
committed
Take into account the "escape-without-double-encode" option in select replacement
1 parent 7ea21f8 commit 1549000

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

src/Converter.php

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -366,9 +366,9 @@ protected static function buildSelect(string $name, string $list, string $select
366366
$input .= $placeholderOption;
367367
$input .= static::$indent.' @foreach ('.$list.' as $optionValue => $optionText)'."\n";
368368
$input .= static::$indent.' <option '."\n";
369-
$input .= static::$indent.' value="{!! e($optionValue, false) !!}" '."\n";
369+
$input .= static::$indent.' value="'.static::escapedEcho('$optionValue').'" '."\n";
370370
$input .= static::$indent.' @selected (in_array($optionValue, (array) ('.static::withOldHelperIfNeeded($name, $selectedValue).')))'."\n";
371-
$input .= static::$indent.' >{!! e($optionText, false) !!}</option>'."\n";
371+
$input .= static::$indent.' >'.static::escapedEcho('$optionText').'</option>'."\n";
372372
$input .= static::$indent.' @endforeach'."\n";
373373
$input .= static::$indent.'</select>';
374374

@@ -461,6 +461,15 @@ protected static function isEmpty(string $value): bool
461461
return \in_array(strtolower($value), ['', "''", '""', 'false', 'null']);
462462
}
463463

464+
protected static function escapedEcho(string $value): string
465+
{
466+
if (static::$escapeWithoutDoubleEncode) {
467+
return '{!! e('.$value.', false) !!}';
468+
}
469+
470+
return '{{ '.$value.' }}';
471+
}
472+
464473
/**
465474
* Examples:
466475
*
@@ -492,11 +501,7 @@ protected static function withEchoIfNeeded(string $value, bool $escape): string
492501
}
493502

494503
if ($escape) {
495-
if (static::$escapeWithoutDoubleEncode) {
496-
return '{!! e('.$value.', false) !!}';
497-
}
498-
499-
return '{{ '.$value.' }}';
504+
return static::escapedEcho($value);
500505
}
501506

502507
return '{!! '.$value.' !!}';

0 commit comments

Comments
 (0)