3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php //$payload = file_get_contents('./csp-log.log'); $payload = "{\"csp-report\":{\"document-uri\":\"http://athleticssite.com/\", \"referrer\":\"\", \"violated-directive\":\"img-src\", \"effective-directive\":\"img-src\", \"original-policy\":\"default-src 'self' https://someurl.com; script-src 'self' 'unsafe-inline' https://use.typekit.com https://google-analytics.com https://ajax.googleapis.com https://js.hsforms.net https://ssl.google-analytics.com; img-src 'self' https://p.typekit.net https://ssl.google-analytics.com ; font-src https://use.typekit.com; report-uri /csp-violations-report-endpoint/;\", \"disposition\":\"report\", \"blocked-uri\":\"https://someurl.com/path/to/file/516.large.jpg?1530632190456\", \"status-code\":200, \"script-sample\":\"\"}} {\"csp-report\":{\"document-uri\":\"http://athleticssite.com/\", \"referrer\":\"\", \"violated-directive\":\"img-src\", \"effective-directive\":\"img-src\", \"original-policy\":\"default-src 'self' https://someurl.com; script-src 'self' 'unsafe-inline' https://use.typekit.com https://google-analytics.com https://ajax.googleapis.com https://js.hsforms.net https://ssl.google-analytics.com; img-src 'self' https://p.typekit.net https://ssl.google-analytics.com ; font-src https://use.typekit.com; report-uri /csp-violations-report-endpoint/;\", \"disposition\":\"report\", \"blocked-uri\":\"https://someurl.com/path/to/file/516.large.jpg?1530632190456\", \"status-code\":200, \"script-sample\":\"\"}}"; $matches = []; preg_match_all('/"blocked-uri":"(.*?)",/m', $payload, $matches); /* for($i = 0; $i < count($matches[1]); $i++) { echo $matches[1][$i] . "\n"; } */ foreach($matches as $match => $uri) { echo $uri[0] . "\n"; }
based on Imtin
Output for 5.6.30, hhvm-3.18.5 - 3.22.0, 7.0.30 - 7.3.0beta1
"blocked-uri":"https://someurl.com/path/to/file/516.large.jpg?1530632190456", https://someurl.com/path/to/file/516.large.jpg?1530632190456