The Wayback Machine - https://web.archive.org/web/20250529114732/https://github.com/symfony/symfony/issues/42255
Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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

Copy link
Copy link
Closed
@Kvizer

Description

@Kvizer
Issue body actions

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

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.