Skip to content
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

Update modified Kint files in ThirdParty #5527

Merged
merged 1 commit into from
Jan 5, 2022
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
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