<commit_before>﻿using System;
using System.Web.Http;

namespace Exceptionless.Api.Controllers {
    [RoutePrefix(API_PREFIX)]
    public class UtilityController : ExceptionlessApiController {
        [HttpGet]
        [Route("search/validate")]
        public IHttpActionResult Validate(string query) {
            if (String.IsNullOrWhiteSpace(query))
                return Ok();

            // TODO: Validate this with a parser.
            if (query.StartsWith("{") || query.EndsWith(":") || query.EndsWith("}"))
                return BadRequest("Invalid character in search query.");

            return Ok();
        }

        [Route("notfound")]
        [HttpGet, HttpPut, HttpPatch, HttpPost, HttpHead]
        public IHttpActionResult Http404(string link) {
            return Ok(new {
                Message = "Not found",
                Url = "http://docs.exceptionless.com"
            });
        }

        [Route("boom")]
        [HttpGet, HttpPut, HttpPatch, HttpPost, HttpHead]
        public IHttpActionResult Boom() {
            throw new ApplicationException("Boom!");
        }
    }
}
<commit_msg>Added authorization to the search validation action.<commit_after>﻿using System;
using System.Web.Http;
using Exceptionless.Core.Authorization;

namespace Exceptionless.Api.Controllers {
    [RoutePrefix(API_PREFIX)]
    public class UtilityController : ExceptionlessApiController {
        [HttpGet]
        [Route("search/validate")]
        [Authorize(Roles = AuthorizationRoles.User)]
        public IHttpActionResult Validate(string query) {
            if (String.IsNullOrWhiteSpace(query))
                return Ok();

            // TODO: Validate this with a parser.
            if (query.StartsWith("{") || query.EndsWith(":") || query.EndsWith("}"))
                return BadRequest("Invalid character in search query.");

            return Ok();
        }

        [Route("notfound")]
        [HttpGet, HttpPut, HttpPatch, HttpPost, HttpHead]
        public IHttpActionResult Http404(string link) {
            return Ok(new {
                Message = "Not found",
                Url = "http://docs.exceptionless.com"
            });
        }

        [Route("boom")]
        [HttpGet, HttpPut, HttpPatch, HttpPost, HttpHead]
        public IHttpActionResult Boom() {
            throw new ApplicationException("Boom!");
        }
    }
}

{'fraction_non_alphanumeric': 0.11502938706968933, 'fraction_numerical': 0.0025188916876574307, 'mean_word_length': 2.168882978723404, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, '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': '5384759', 'n_tokens_mistral': 633, 'n_tokens_neox': 622, 'n_words': 146}