Skip to content

Conversation

@kesselb
Copy link

@kesselb kesselb commented Aug 10, 2021

Fix #299

Note: My knowledge about css parsing is limited. I'm not sure if that's a proper fix 🙈

Copy link
Contributor

@bytestream bytestream left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the attrib part of the ABNF isn't actually implemented:

// attrib
//   : '[' S* IDENT S* [ [ '=' | INCLUDES | DASHMATCH ] S*
//     [ IDENT | STRING ] S* ]? ']'

I think the simple_selector regex should be updated?

$components = preg_split('/([#.:\[\]])/', $x, -1, PREG_SPLIT_DELIM_CAPTURE);

Two other points to note:

  • GitHub CI isn't running the ExtractStyleBlocksTest because there is no csstidy implementation... (2582405)
  • Is it intended that * img[tabindex=\"0\"] + div becomes * img + div as that has different meaning to what was originally intended? body.class[foo="attr"] {text-align:right;} for example gets completely removed

@PHPGangsta
Copy link
Contributor

Hi,

I also experienced that bug 2 years ago or so, and I quickly fixed it by changing line 243 to this:

if ($y === '*' || strpos($y, '[') !== false || isset($html_definition->info[$y = strtolower($y)])) {

Which means I introduced this check: || strpos($y, '[') !== false

It works very good since then 😃 But I would prefer to have a 100% correct solution upstream of cause 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Selector for element with attribute is lost

3 participants