Skip to content

Commit 8034422

Browse files
committed
Merge pull request #5527 from paulbalandan/kint-4.1.1
Update modified Kint files in `ThirdParty`
1 parent e1f40c5 commit 8034422

File tree

2 files changed

+39
-5
lines changed

2 files changed

+39
-5
lines changed

system/ThirdParty/Kint/Renderer/CliRenderer.php

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,15 @@ class CliRenderer extends TextRenderer
5959
*/
6060
public static $min_terminal_width = 40;
6161

62+
/**
63+
* Which stream to check for VT100 support on windows.
64+
*
65+
* null uses STDOUT if it's defined
66+
*
67+
* @var null|resource
68+
*/
69+
public static $windows_stream = null;
70+
6271
protected static $terminal_width = null;
6372

6473
protected $windows_output = false;
@@ -69,8 +78,22 @@ public function __construct()
6978
{
7079
parent::__construct();
7180

72-
if (!self::$force_utf8) {
73-
$this->windows_output = KINT_WIN;
81+
if (!self::$force_utf8 && KINT_WIN) {
82+
if (!KINT_PHP72) {
83+
$this->windows_output = true;
84+
} else {
85+
$stream = self::$windows_stream;
86+
87+
if (!$stream && \defined('STDOUT')) {
88+
$stream = STDOUT;
89+
}
90+
91+
if (!$stream) {
92+
$this->windows_output = true;
93+
} else {
94+
$this->windows_output = !\sapi_windows_vt100_support($stream);
95+
}
96+
}
7497
}
7598

7699
if (!self::$terminal_width) {
@@ -153,7 +176,7 @@ protected function utf8ToWindows($string)
153176
{
154177
return \str_replace(
155178
['', '', '', '', '', '', ''],
156-
["\xda", "\xdc", "\xbf", "\xb3", "\xc0", "\xc4", "\xd9"],
179+
[' ', '=', ' ', '|', ' ', '-', ' '],
157180
$string
158181
);
159182
}

system/ThirdParty/Kint/Renderer/RichRenderer.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,9 @@ class RichRenderer extends Renderer
133133

134134
public static $always_pre_render = false;
135135

136+
public static $js_nonce = null;
137+
public static $css_nonce = null;
138+
136139
protected $plugin_objs = [];
137140
protected $expand = false;
138141
protected $force_pre_render = false;
@@ -389,10 +392,18 @@ public function preRender()
389392

390393
switch ($type) {
391394
case 'script':
392-
$output .= '<script class="kint-rich-script">'.$contents.'</script>';
395+
$output .= '<script class="kint-rich-script"';
396+
if (null !== self::$js_nonce) {
397+
$output .= ' nonce="'.\htmlspecialchars(self::$js_nonce).'"';
398+
}
399+
$output .= '>'.$contents.'</script>';
393400
break;
394401
case 'style':
395-
$output .= '<style class="kint-rich-style">'.$contents.'</style>';
402+
$output .= '<style class="kint-rich-style"';
403+
if (null !== self::$css_nonce) {
404+
$output .= ' nonce="'.\htmlspecialchars(self::$css_nonce).'"';
405+
}
406+
$output .= '>'.$contents.'</style>';
396407
break;
397408
default:
398409
$output .= $contents;

0 commit comments

Comments
 (0)