Skip to content

Symfony DomCrawler doesn't allow get html5Parser's errors #42255

@Kvizer

Description

@Kvizer

Symfony version(s) affected:
symfony/dom-crawler 5.2.10

Description
<meta http-equiv="Content-Type" content="text/html; charset=unicode">
Parsing an HTML document with Crawler and meta http-equiv mentioned above, then retrieving the result, and all nodes are empty although *Symfony\Component\DomCrawler\Crawler*html5Parser has errors - Line 0, Col 0: Unexpected text. Ignoring... no chance to get this error, crawler doesn't allow us to get error

How to reproduce

use Symfony\Component\DomCrawler\Crawler;

$html = <<<'HTML'
<!doctype html>
<html>
 <head> 
  <meta http-equiv="Content-Type" content="text/html; charset=unicode"> 
  <meta name="ProgId" content="Word.Document"> 
  <meta name="Generator" content="Microsoft Word 14"> 
  <meta name="Originator" content="Microsoft Word 14"> 
 </head> 
  <body>
        <p class="message">Hello World!</p>
        <p>Hello Crawler!</p>
  </body>
</html>
HTML;

$crawler = new Crawler($html);

$htmlResult = $crawler->outerHtml();

Possible Solution

add getter to $html5Parser or make it protected

Additional context
image_2021_07_26T09_37_36_181Z

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy