<commit_before><?php

class ExceptionalData {

    protected $exception;
    protected $backtrace = array();

    function __construct(Exception $exception) {
        $this->exception = $exception;

        $trace = $this->exception->getTrace();
        foreach ($trace as $t) {
            if (!isset($t["file"])) continue;
            $this->backtrace[] = "$t[file]:$t[line]:in `$t[function]\'";
        }

        // environment data
        $data = ExceptionalEnvironment::to_array();

        // exception data
        $message = $this->exception->getMessage();
        $now = date("c");

        // spoof 404 error
        $error_class = get_class($this->exception);
        if ($error_class == "Http404Error") {
            $error_class = "ActionController::UnknownAction";
        }

        $data["exception"] = array(
            "exception_class" => $error_class,
            "message" => $message,
            "backtrace" => $this->backtrace,
            "occurred_at" => $now
        );

        // context
        $context = Exceptional::$context;
        if (!empty($context)) {
            $data["context"] = $context;
        }

        if (isset($_SERVER["HTTP_HOST"])) {

            // request data
            $session = isset($_SESSION) ? $_SESSION : array();

            // sanitize headers
            $headers = getallheaders();
            if (isset($headers["Cookie"])) {
              $sessionKey = preg_quote(ini_get("session.name"), "/");
              $headers["Cookie"] = preg_replace("/$sessionKey=\S+/", "$sessionKey=[FILTERED]", $headers["Cookie"]);
            }

            $server = $_SERVER;
            $keys = array("HTTPS", "HTTP_HOST", "REQUEST_URI", "REQUEST_METHOD", "REMOTE_ADDR");
            $this->fill_keys($server, $keys);

            $protocol = $server["HTTPS"] && $server["HTTPS"] != "off" ? "https://" : "http://";
            $url = $server["HTTP_HOST"] ? "$protocol$server[HTTP_HOST]$server[REQUEST_URI]" : "";

            $data["request"] = array(
                "url" => $url,
                "request_method" => strtolower($server["REQUEST_METHOD"]),
                "remote_ip" => $server["REMOTE_ADDR"],
                "headers" => $headers,
                "session" => $session
            );

            if (!empty(Exceptional::$controller) && !empty(Exceptional::$action)) {
                $data["request"]["controller"] = Exceptional::$controller;
                $data["request"]["action"] = Exceptional::$action;
            }

            $params = array_merge($_GET, $_POST);

						foreach (Exceptional::$blacklist as $filter)
						{
							$params[$filter] = '';
						}
						
            if (!empty($params)) {
                $data["request"]["parameters"] = $params;<commit_msg>don't pass in empty strings for blacklisted params that aren't set in the first place<commit_after><?php

class ExceptionalData {

    protected $exception;
    protected $backtrace = array();

    function __construct(Exception $exception) {
        $this->exception = $exception;

        $trace = $this->exception->getTrace();
        foreach ($trace as $t) {
            if (!isset($t["file"])) continue;
            $this->backtrace[] = "$t[file]:$t[line]:in `$t[function]\'";
        }

        // environment data
        $data = ExceptionalEnvironment::to_array();

        // exception data
        $message = $this->exception->getMessage();
        $now = date("c");

        // spoof 404 error
        $error_class = get_class($this->exception);
        if ($error_class == "Http404Error") {
            $error_class = "ActionController::UnknownAction";
        }

        $data["exception"] = array(
            "exception_class" => $error_class,
            "message" => $message,
            "backtrace" => $this->backtrace,
            "occurred_at" => $now
        );

        // context
        $context = Exceptional::$context;
        if (!empty($context)) {
            $data["context"] = $context;
        }

        if (isset($_SERVER["HTTP_HOST"])) {

            // request data
            $session = isset($_SESSION) ? $_SESSION : array();

            // sanitize headers
            $headers = getallheaders();
            if (isset($headers["Cookie"])) {
              $sessionKey = preg_quote(ini_get("session.name"), "/");
              $headers["Cookie"] = preg_replace("/$sessionKey=\S+/", "$sessionKey=[FILTERED]", $headers["Cookie"]);
            }

            $server = $_SERVER;
            $keys = array("HTTPS", "HTTP_HOST", "REQUEST_URI", "REQUEST_METHOD", "REMOTE_ADDR");
            $this->fill_keys($server, $keys);

            $protocol = $server["HTTPS"] && $server["HTTPS"] != "off" ? "https://" : "http://";
            $url = $server["HTTP_HOST"] ? "$protocol$server[HTTP_HOST]$server[REQUEST_URI]" : "";

            $data["request"] = array(
                "url" => $url,
                "request_method" => strtolower($server["REQUEST_METHOD"]),
                "remote_ip" => $server["REMOTE_ADDR"],
                "headers" => $headers,
                "session" => $session
            );

            if (!empty(Exceptional::$controller) && !empty(Exceptional::$action)) {
                $data["request"]["controller"] = Exceptional::$controller;
                $data["request"]["action"] = Exceptional::$action;
            }

            $params = array_merge($_GET, $_POST);

						foreach (Exceptional::$blacklist as $filter) {
							if (isset($params[$filter])) {
								$params[$filter] = '';
							}
						}
						
            if (!empty($params)) {
                $data["request"]["parameters"] = $params;
{'fraction_non_alphanumeric': 0.1761786600496278, 'fraction_numerical': 0.0021269053527118043, 'mean_word_length': 2.046976241900648, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 39, 'https://': 2, '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': '4471073', 'n_tokens_mistral': 1640, 'n_tokens_neox': 1532, 'n_words': 279}