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

Use mb_detect_encoding with $strict = true #16359

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

Merged
merged 1 commit into from
Oct 28, 2015
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
Use mb_detect_encoding with $strict = true
  • Loading branch information
nicolas-grekas committed Oct 27, 2015
commit e6c89f15e4b8bcc8eb4e35dd0219b121f5e34487
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public function testLogUTF8LongString()
$dbalLogger
->expects($this->once())
->method('log')
->with('SQL', array('short' => $shortString, 'long' => mb_substr($longString, 0, DbalLogger::MAX_STRING_LENGTH - 6, mb_detect_encoding($longString)).' [...]'))
->with('SQL', array('short' => $shortString, 'long' => mb_substr($longString, 0, DbalLogger::MAX_STRING_LENGTH - 6, 'UTF-8').' [...]'))
;

$dbalLogger->startQuery('SQL', array(
Expand Down
4 changes: 2 additions & 2 deletions 4 src/Symfony/Component/Console/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -1089,7 +1089,7 @@ private function stringWidth($string)
return strlen($string);
}

if (false === $encoding = mb_detect_encoding($string)) {
if (false === $encoding = mb_detect_encoding($string, null, true)) {
return strlen($string);
}

Expand All @@ -1106,7 +1106,7 @@ private function splitStringByWidth($string, $width)
return str_split($string, $width);
}

if (false === $encoding = mb_detect_encoding($string)) {
if (false === $encoding = mb_detect_encoding($string, null, true)) {
return str_split($string, $width);
}

Expand Down
2 changes: 1 addition & 1 deletion 2 src/Symfony/Component/Console/Helper/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ protected function strlen($string)
return strlen($string);
}

if (false === $encoding = mb_detect_encoding($string)) {
if (false === $encoding = mb_detect_encoding($string, null, true)) {
return strlen($string);
}

Expand Down
2 changes: 1 addition & 1 deletion 2 src/Symfony/Component/Console/Helper/TableHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ private function renderCell(array $row, $column, $cellFormat)
$width = $this->getColumnWidth($column);

// str_pad won't work properly with multi-byte strings, we need to fix the padding
if (function_exists('mb_strwidth') && false !== $encoding = mb_detect_encoding($cell)) {
if (function_exists('mb_strwidth') && false !== $encoding = mb_detect_encoding($cell, null, true)) {
$width += strlen($cell) - mb_strwidth($cell, $encoding);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public function reverseTransform($value)
throw new TransformationFailedException('I don\'t have a clear idea what infinity looks like');
}

if (function_exists('mb_detect_encoding') && false !== $encoding = mb_detect_encoding($value)) {
if (function_exists('mb_detect_encoding') && false !== $encoding = mb_detect_encoding($value, null, true)) {
$length = mb_strlen($value, $encoding);
$remainder = mb_substr($value, $position, $length, $encoding);
} else {
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.