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 f70bcf6

Browse filesBrowse files
bug #37514 [String] throw when Alpine is used and translit fails (nicolas-grekas)
This PR was merged into the 5.0 branch. Discussion ---------- [String] throw when Alpine is used and translit fails | Q | A | ------------- | --- | Branch? | 5.0 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #37213 | License | MIT | Doc PR | - Commits ------- 98f5d50 [String] throw when Alpine is used and translit fails
2 parents d285042 + 98f5d50 commit f70bcf6
Copy full SHA for f70bcf6

File tree

Expand file treeCollapse file tree

1 file changed

+4
-2
lines changed
Filter options
Expand file treeCollapse file tree

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.