<commit_before><?php

namespace PicoFeed\Parser;

use Closure;
use DomDocument;
use SimpleXmlElement;

/**
 * XML parser class.
 *
 * Checks for XML eXternal Entity (XXE) and XML Entity Expansion (XEE) attacks on XML documents
 *
 * @author  <NAME>
 */
class XmlParser
{
    /**
     * Get a SimpleXmlElement instance or return false.
     *
     * @static
     *
     * @param string $input XML content
     *
     * @return mixed
     */
    public static function getSimpleXml($input)
    {
        $dom = self::getDomDocument($input);

        if ($dom !== false) {
            $simplexml = simplexml_import_dom($dom);

            if (!$simplexml instanceof SimpleXmlElement) {
                return false;
            }

            return $simplexml;
        }

        return false;
    }

    /**
     * @return true if it a vulnerable php-fpm version is used
     */
    public static function isRunningVulnerableFpm()
    {
        $isUnpatched = version_compare(PHP_VERSION, '5.5.22', 'lt') || (
            version_compare(PHP_VERSION, '5.6', 'gte') &&
            version_compare(PHP_VERSION, '5.6.6', 'lt')
        );

        return substr(php_sapi_name(), 0, 3) === 'fpm' && $isUnpatched;
    }

    /**<commit_msg>fix method visibility<commit_after><?php

namespace PicoFeed\Parser;

use Closure;
use DomDocument;
use SimpleXmlElement;

/**
 * XML parser class.
 *
 * Checks for XML eXternal Entity (XXE) and XML Entity Expansion (XEE) attacks on XML documents
 *
 * @author  <NAME>
 */
class XmlParser
{
    /**
     * Get a SimpleXmlElement instance or return false.
     *
     * @static
     *
     * @param string $input XML content
     *
     * @return mixed
     */
    public static function getSimpleXml($input)
    {
        $dom = self::getDomDocument($input);

        if ($dom !== false) {
            $simplexml = simplexml_import_dom($dom);

            if (!$simplexml instanceof SimpleXmlElement) {
                return false;
            }

            return $simplexml;
        }

        return false;
    }

    /**
     * @return true if it a vulnerable php-fpm version is used
     */
    private static function isRunningVulnerableFpm()
    {
        $isUnpatchedPhp = version_compare(PHP_VERSION, '5.5.22', 'lt') || (
            version_compare(PHP_VERSION, '5.6', 'gte') &&
            version_compare(PHP_VERSION, '5.6.6', 'lt')
        );

        return substr(php_sapi_name(), 0, 3) === 'fpm' && $isUnpatchedPhp;
    }

    /**
{'fraction_non_alphanumeric': 0.12172511084240226, 'fraction_numerical': 0.00886739218057235, 'mean_word_length': 2.106382978723404, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 8}, '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': '2955774', 'n_tokens_mistral': 783, 'n_tokens_neox': 758, 'n_words': 196}