Commit 4dd1278d authored by Märt Rang's avatar Märt Rang Committed by Youri van Koppen
Browse files

Issue #3257379 by rang501: Skip call to function...

Issue #3257379 by rang501: Skip call to function libxml_disable_entity_loader() on PHP8 since it is deprecated.
parent 40091138
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -25,6 +25,8 @@ trait XmlParserTrait {
   * The previous value of the entity loader.
   *
   * @var bool
   *
   * @todo remove when Drupal 9 (and thus PHP 7) is no longer supported.
   */
  protected static $_entityLoader;

@@ -75,7 +77,15 @@ trait XmlParserTrait {
   */
  protected static function startXmlErrorHandling() {
    static::$_useError = libxml_use_internal_errors(TRUE);

    // This mitigates a security issue in libxml older than version 2.9.0.
    // See http://symfony.com/blog/security-release-symfony-2-0-17-released for
    // details.
    // @todo remove when Drupal 9 (and thus PHP 7) is no longer supported.
    if (\PHP_VERSION_ID < 80000) {
      static::$_entityLoader = libxml_disable_entity_loader(TRUE);
    }

    libxml_clear_errors();
  }

@@ -92,8 +102,12 @@ trait XmlParserTrait {
    }
    libxml_clear_errors();
    libxml_use_internal_errors(static::$_useError);

    // @todo remove when Drupal 9 (and thus PHP 7) is no longer supported.
    if (\PHP_VERSION_ID < 80000) {
      libxml_disable_entity_loader(static::$_entityLoader);
    }
  }

  /**
   * Returns the errors reported during parsing.
+11 −0
Original line number Diff line number Diff line
@@ -69,12 +69,23 @@ class Feed {
   */
  public static function findFeed($url, $html) {
    $use_error = libxml_use_internal_errors(TRUE);

    // This mitigates a security issue in libxml older than version 2.9.0.
    // See http://symfony.com/blog/security-release-symfony-2-0-17-released for
    // details.
    // @todo remove when Drupal 9 (and thus PHP 7) is no longer supported.
    if (\PHP_VERSION_ID < 80000) {
      $entity_loader = libxml_disable_entity_loader(TRUE);
    }

    $dom = new \DOMDocument();
    $status = $dom->loadHTML(trim($html));

    // @todo remove when Drupal 9 (and thus PHP 7) is no longer supported.
    if (\PHP_VERSION_ID < 80000) {
      libxml_disable_entity_loader($entity_loader);
    }

    libxml_use_internal_errors($use_error);

    if (!$status) {