Skip to content

Commit

Permalink
Merge pull request #5527 from paulbalandan/kint-4.1.1
Browse files Browse the repository at this point in the history
Update modified Kint files in `ThirdParty`
  • Loading branch information
kenjis committed Jan 8, 2022
1 parent e1f40c5 commit 8034422
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 5 deletions.
29 changes: 26 additions & 3 deletions system/ThirdParty/Kint/Renderer/CliRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,15 @@ class CliRenderer extends TextRenderer
*/
public static $min_terminal_width = 40;

/**
* Which stream to check for VT100 support on windows.
*
* null uses STDOUT if it's defined
*
* @var null|resource
*/
public static $windows_stream = null;

protected static $terminal_width = null;

protected $windows_output = false;
Expand All @@ -69,8 +78,22 @@ public function __construct()
{
parent::__construct();

if (!self::$force_utf8) {
$this->windows_output = KINT_WIN;
if (!self::$force_utf8 && KINT_WIN) {
if (!KINT_PHP72) {
$this->windows_output = true;
} else {
$stream = self::$windows_stream;

if (!$stream && \defined('STDOUT')) {
$stream = STDOUT;
}

if (!$stream) {
$this->windows_output = true;
} else {
$this->windows_output = !\sapi_windows_vt100_support($stream);
}
}
}

if (!self::$terminal_width) {
Expand Down Expand Up @@ -153,7 +176,7 @@ protected function utf8ToWindows($string)
{
return \str_replace(
['', '', '', '', '', '', ''],
["\xda", "\xdc", "\xbf", "\xb3", "\xc0", "\xc4", "\xd9"],
[' ', '=', ' ', '|', ' ', '-', ' '],
$string
);
}
Expand Down
15 changes: 13 additions & 2 deletions system/ThirdParty/Kint/Renderer/RichRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ class RichRenderer extends Renderer

public static $always_pre_render = false;

public static $js_nonce = null;
public static $css_nonce = null;

protected $plugin_objs = [];
protected $expand = false;
protected $force_pre_render = false;
Expand Down Expand Up @@ -389,10 +392,18 @@ public function preRender()

switch ($type) {
case 'script':
$output .= '<script class="kint-rich-script">'.$contents.'</script>';
$output .= '<script class="kint-rich-script"';
if (null !== self::$js_nonce) {
$output .= ' nonce="'.\htmlspecialchars(self::$js_nonce).'"';
}
$output .= '>'.$contents.'</script>';
break;
case 'style':
$output .= '<style class="kint-rich-style">'.$contents.'</style>';
$output .= '<style class="kint-rich-style"';
if (null !== self::$css_nonce) {
$output .= ' nonce="'.\htmlspecialchars(self::$css_nonce).'"';
}
$output .= '>'.$contents.'</style>';
break;
default:
$output .= $contents;
Expand Down

0 comments on commit 8034422

Please sign in to comment.