-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Bug: KINT d()
visual error in debugging when activating CSP
#5475
Comments
@davidalmaraz Thank you for reporitng. But Kint is a third party library, so we can't change files in it. |
The workaround is to use |
function d(...$vars)
{
Kint::$aliases[] = 'd';
ob_start();
Kint::dump(...$vars);
$output = ob_get_clean();
/** @var \Config\App $config */
$config = config('App');
if ($config->CSPEnabled === true) {
$output = str_replace('<script ', '<script {csp-script-nonce} ', $output);
$output = str_replace('<style ', '<style {csp-style-nonce} ', $output);
}
echo $output;
} |
d()
visual error in debugging when activating CONTENT SECURITY POLICY
Kint has magical Modifiers: If you use the wrapper functions (or CI4 provides them), the Modifiers do not work. This should be handled by Kint. |
d()
visual error in debugging when activating CONTENT SECURITY POLICYd()
visual error in debugging when activating CSP
@davidalmaraz |
#5501 was merged into develop. |
PHP Version
7.4
CodeIgniter4 Version
4.1.5
CodeIgniter4 Installation Method
Manual (zip or tar.gz)
Which operating systems have you tested for this bug?
Windows
Which server did you use?
apache
Database
No response
What happened?
kint-rich-script and kint-rich-style in RichRenderer.php inside thirdparty KIN need to put {csp-style-nonce} and {csp-script-nonce} because when "CONTENT SECURITY POLICY" is activated it disables it for security for the same. What causes that being in debug mode with CSP activated disables its visual style.
Steps to Reproduce
Activate developer mode and CSP.
Use
d('example');
in some controller to debugExpected Output
Being able to see the theme used by kint in the web browser for debugging
Anything else?
into folder system/ThirdParty/Kint/Renderer/ in file RichRenderer.php into line 383 a 392
switch ($type) { case 'script': $output .= '<script class="kint-rich-script">'.$contents.'</script>'; break; case 'style': $output .= '<style class="kint-rich-style">'.$contents.'</style>'; break; default: $output .= $contents; }
replace by:
switch ($type) { case 'script': $output .= '<script {csp-script-nonce} class="kint-rich-script">'.$contents.'</script>'; break; case 'style': $output .= '<style {csp-style-nonce} class="kint-rich-style">'.$contents.'</style>'; break; default: $output .= $contents; }
To return the visual style of KINT when CSP is activated
The text was updated successfully, but these errors were encountered: