<commit_before><?php
namespace MOC\Redirects\Routing;

use Doctrine\ORM\QueryBuilder;
use TYPO3\Flow\Annotations as Flow;
use TYPO3\Flow\Core\Bootstrap;
use TYPO3\Flow\Http\Uri;
use TYPO3\Flow\Mvc\Routing\DynamicRoutePart;
use TYPO3\TYPO3CR\Domain\Model\NodeData;

/**
 * A route part handler for finding nodes specifically in the website's frontend.
 */
class RedirectFrontendNodeRoutePartHandler extends DynamicRoutePart
{

    /**
     * @Flow\Inject
     * @var \Doctrine\Common\Persistence\ObjectManager
     */
    protected $entityManager;

    /**
     * @Flow\Inject
     * @var Bootstrap
     */
    protected $bootstrap;

    /**
     * @param string $requestPath The request path to be matched
     * @return string value to match
     */
    protected function findValueToMatch($requestPath)
    {
        return $requestPath;
    }

    /**
     * @param string $requestPath
     * @return boolean TRUE if the $requestPath could be matched, otherwise FALSE
     */
    protected function matchValue($requestPath)
    {
        /** @var Uri $uri */
        $uri = $this->bootstrap->getActiveRequestHandler()->getHttpRequest()->getUri();
        $relativeUrl = rtrim($uri->getPath(), '/');
        $relativeUrlWithQueryString = $relativeUrl . ($uri->getQuery() ? '?' . $uri->getQuery() : '');
        $absoluteUrl = $uri->getHost() . $relativeUrl;
        $absoluteUrlWithQueryString = $uri->getHost() . $relativeUrlWithQueryString;

        if (empty($relativeUrl)) {
            return false;
        }

        /** @var QueryBuilder $queryBuilder */
        $queryBuilder = $this->entityManager->createQueryBuilder();

        $queryBuilder->select('n')
          ->distinct()
          ->from('TYPO3\TYPO3CR\Domain\Model\NodeData', 'n')
          ->where('n.workspace = :workspace')
          ->setParameter('workspace', 'live')
          ->andWhere('n.properties LIKE :relativeUrl')
          ->setParameter('relativeUrl', '%"redirectUrl"%' . json_encode($relativeUrl) . '%');

        $query = $queryBuilder->getQuery();
        $nodes = $query->getResult();

        if (empty($nodes)) {
            return false;<commit_msg>[BUGFIX] Add slashes to json like statement<commit_after><?php
namespace MOC\Redirects\Routing;

use Doctrine\ORM\QueryBuilder;
use TYPO3\Flow\Annotations as Flow;
use TYPO3\Flow\Core\Bootstrap;
use TYPO3\Flow\Http\Uri;
use TYPO3\Flow\Mvc\Routing\DynamicRoutePart;
use TYPO3\TYPO3CR\Domain\Model\NodeData;

/**
 * A route part handler for finding nodes specifically in the website's frontend.
 */
class RedirectFrontendNodeRoutePartHandler extends DynamicRoutePart
{

    /**
     * @Flow\Inject
     * @var \Doctrine\Common\Persistence\ObjectManager
     */
    protected $entityManager;

    /**
     * @Flow\Inject
     * @var Bootstrap
     */
    protected $bootstrap;

    /**
     * @param string $requestPath The request path to be matched
     * @return string value to match
     */
    protected function findValueToMatch($requestPath)
    {
        return $requestPath;
    }

    /**
     * @param string $requestPath
     * @return boolean TRUE if the $requestPath could be matched, otherwise FALSE
     */
    protected function matchValue($requestPath)
    {
        /** @var Uri $uri */
        $uri = $this->bootstrap->getActiveRequestHandler()->getHttpRequest()->getUri();
        $relativeUrl = rtrim($uri->getPath(), '/');
        $relativeUrlWithQueryString = $relativeUrl . ($uri->getQuery() ? '?' . $uri->getQuery() : '');
        $absoluteUrl = $uri->getHost() . $relativeUrl;
        $absoluteUrlWithQueryString = $uri->getHost() . $relativeUrlWithQueryString;

        if (empty($relativeUrl)) {
            return false;
        }

        /** @var QueryBuilder $queryBuilder */
        $queryBuilder = $this->entityManager->createQueryBuilder();

        $queryBuilder->select('n')
          ->distinct()
          ->from('TYPO3\TYPO3CR\Domain\Model\NodeData', 'n')
          ->where('n.workspace = :workspace')
          ->setParameter('workspace', 'live')
          ->andWhere('n.properties LIKE :relativeUrl')
          ->setParameter('relativeUrl', '%"redirectUrl"%' . addslashes(json_encode($relativeUrl)) . '%');

        $query = $queryBuilder->getQuery();
        $nodes = $query->getResult();

        if (empty($nodes)) {
            return false;
{'fraction_non_alphanumeric': 0.14226327944572748, 'fraction_numerical': 0.003695150115473441, 'mean_word_length': 2.7628149435273675, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 43, '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': '1116993', 'n_tokens_mistral': 1271, 'n_tokens_neox': 1255, 'n_words': 259}