8000 CSS Selector fail to select element with colon char in ID · Issue #44516 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
CSS Selector fail to select element with colon char in ID #44516
Closed
@gabrielpl

Description

@gabrielpl

Symfony version(s) affected

5.4.0

Description

I´m using DomCrawler and CssSelector components to parse XML pages.
If the ID attribute of a tag has a colon char, the ID selector (#) fail to find the element.

How to reproduce

$xml = <<<XML
<?xml version="1.0" encoding="UTF-8"?>
<content>
  <tag id="test">foo</tag>
  <tag id="test:colon">bar</tag>
</content>
XML;

$crawler = new Crawler();
$crawler->addXmlContent($xml);

var_dump(
    $crawler->filter('#test')->count(),
    $crawler->filter('#test\:colon')->count() // notice the colon char is escaped
);

Possible Solution

No response

Additional Context

No response

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

      0