Skip to content

soup: a quoted comma in an attribute value silently empties a selector list #191

Closed

Description

@elena-oaklight

Summary

A comma inside a quoted attribute value makes the selector-list splitter cut the list in the wrong place. The result is an empty list with no exception — and it discards the matches of groups in the same list that parse fine.

Found while re-checking #182 at 291042d. It is pre-existing (the same behaviour is on the base commit), so it is not a regression from that PR, and it only ever under-matches — it cannot widen a match, which is why it is filed separately rather than raised as a blocker there.

Reproduction

from soup import Soup

HTML = """<div>
  <a id="t1" title="a]b">one</a>
  <a id="t2" title="a,b">two</a>
  <a id="t3" title="c">three</a>
</div>"""

Soup(HTML).select('[title="a,b"]')                # ['t2']        correct
Soup(HTML).select('[title="a,b"], [title="c"]')   # []            expected ['t2', 't3']
Soup(HTML).select('[title="c"], [title="a,b"]')   # []            expected ['t2', 't3']

soupsieve 2.10 (the bench-soup pin) returns ['t2', 't3'] in both list cases.

[title="a,b"] on its own is parsed correctly, so the attribute parser is not at fault — the group separator is split without regard for quotes.

Why it matters

#182's contract is that attribute syntax the parser cannot read raises instead of dropping the constraint silently. This is the one form that still drops silently, and it is worse than dropping a constraint: a selector list whose other groups are perfectly parseable returns nothing at all. A caller gets an empty result with no signal.

A related case, also silent:

Soup(HTML).select('bogus::nonsense')              # []
Soup(HTML).select('[title="c"], bogus::nonsense') # []

Suggested direction

Either make the group splitter quote-aware, or reject an unparseable group the way #182 rejects unparseable attribute syntax. The first is more useful, since [title="a,b"] is valid CSS and already parses correctly in isolation.

Activity

  1. added a commit that references this issue on Oct 13, 2026
    9fdd409
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions