humanmade / humanmade/altis-browser-security
Add nonces for inline scripts to CSP
Open
- Dominant language
- PHP
- Stars
- 10
- Forks
- 3
- PR merge metrics
- No merged PRs in 30d
Description
This code works well so far but would be good to figure out some configurability. Also needs a lot of cross browser testing.
```php
add_action( 'template_redirect', function () {
// Collect full page output.
ob_start( function ( $output ) {
$nonces = [];
$output = preg_replace_callback( '##', function ( $matches ) use ( &$nonces ) {
$nonce = wp_create_nonce( $matches[0] );
$nonces[] = $nonce;
return str_replace( '
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.