<commit_before><?php
namespace Hostnet\HnDependencyInjectionPlugin;

use Symfony\Component\HttpKernel\Event\FilterResponseEvent;

/**
 * Makes sure the Symfony1Panel gets the profiler debug URL.
 *
 * A scenario
 * - New (dev) request for Symfony 2
 * - Routing misses, fall back to Symfony 1
 * - Symfony 1 runs and sends it response, including Symfony1Panel
 * - Symfony 2 kernel.response event is triggered
 * - Prio -100: - The ProfilerListener collects dev info
 * -            - Profiler adds the x-debug-token in the headers
 * - Prio -128: - WebDebugToolbarListener puts the x-debug-token-link in the response
 * - Prio -129: - DebugUrlTracker (us) inserts the link to the Symfony1Panel
 *
 * Only registered in dev mode for efficiency
 * @author <NAME> <<EMAIL>>
 */
class DebugUrlTracker
{
    private $url;

    public function onKernelResponse(FilterResponseEvent $event)
    {
        if ($this->url || ! $event->isMasterRequest() || ! \sfContext::hasInstance()) {
            return;
        }
        $response_headers = $event->getResponse()->headers;
        if ($response_headers->has('x-debug-token-link')) {
            $this->url = $response_headers->get('x-debug-token-link');
            $link = json_encode($response_headers->get('x-debug-token-link'));
            echo <<<JAVASCRIPT
<script>
(function() {
  var element = document.querySelector("#sfWebDebugDetails a[title=sf2]");
  element.href= $link;
  element.onclick='';
}())
</script>
JAVASCRIPT;
        }
    }
}<commit_msg>Made exclusion rule for content types which include javascript<commit_after><?php
namespace Hostnet\HnDependencyInjectionPlugin;

use Symfony\Component\HttpKernel\Event\FilterResponseEvent;

/**
 * Makes sure the Symfony1Panel gets the profiler debug URL.
 *
 * A scenario
 * - New (dev) request for Symfony 2
 * - Routing misses, fall back to Symfony 1
 * - Symfony 1 runs and sends it response, including Symfony1Panel
 * - Symfony 2 kernel.response event is triggered
 * - Prio -100: - The ProfilerListener collects dev info
 * -            - Profiler adds the x-debug-token in the headers
 * - Prio -128: - WebDebugToolbarListener puts the x-debug-token-link in the response
 * - Prio -129: - DebugUrlTracker (us) inserts the link to the Symfony1Panel
 *
 * Only registered in dev mode for efficiency
 * @author <NAME> <<EMAIL>>
 */
class DebugUrlTracker
{
    private $url;

    public function onKernelResponse(FilterResponseEvent $event)
    {
        if ($this->url || ! $event->isMasterRequest() || ! \sfContext::hasInstance()) {
            return;
        }
        $response_headers = $event->getResponse()->headers;
        if ($response_headers->has('x-debug-token-link')
            // Only add when the symfony 1 content type is not javascrupt
            && strpos(\sfContext::getInstance()->getResponse()->getContentType(), 'javascript') === false
        ) {
            $this->url = $response_headers->get('x-debug-token-link');
            $link = json_encode($response_headers->get('x-debug-token-link'));
            echo <<<JAVASCRIPT
<script>
(function() {
  var element = document.querySelector("#sfWebDebugDetails a[title=sf2]");
  element.href= $link;
  element.onclick='';
}())
</script>
JAVASCRIPT;
        }
    }
}
{'fraction_non_alphanumeric': 0.1263060848186847, 'fraction_numerical': 0.0107559926244622, 'mean_word_length': 3.1945876288659796, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2012318', 'n_tokens_mistral': 980, 'n_tokens_neox': 944, 'n_words': 264}