Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 98f5d50

Browse filesBrowse files
[String] throw when Alpine is used and translit fails
1 parent d285042 commit 98f5d50
Copy full SHA for 98f5d50

File tree

1 file changed

+4
-2
lines changed
Filter options

1 file changed

+4
-2
lines changed

‎src/Symfony/Component/String/AbstractUnicodeString.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/String/AbstractUnicodeString.php
+4-2Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,10 @@ public function ascii(array $rules = []): self
142142
} elseif (ICONV_IMPL === 'glibc') {
143143
$s = iconv('UTF-8', 'ASCII//TRANSLIT', $s);
144144
} else {
145-
$s = preg_replace_callback('/[^\x00-\x7F]/u', static function ($c) {
146-
$c = iconv('UTF-8', 'ASCII//IGNORE//TRANSLIT', $c[0]);
145+
$s = @preg_replace_callback('/[^\x00-\x7F]/u', static function ($c) {
146+
if ('' === $c = (string) iconv('UTF-8', 'ASCII//IGNORE//TRANSLIT', $c[0])) {
147+
throw new \LogicException(sprintf('"%s" requires a translit-able iconv implementation, try installing "gnu-libiconv" if you\'re using Alpine Linux.', static::class));
148+
}
147149

148150
return 1 < \strlen($c) ? ltrim($c, '\'`"^~') : (\strlen($c) ? $c : '?');
149151
}, $s);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.