Skip to content

Attribute selectors vs \n in values #233

@zverok

Description

@zverok

Hi! Thanks for the powerful library.

I use it via BeautifulSoup, and I find out this behavior:

from bs4 import BeautifulSoup

soup = BeautifulSoup("<p><span title='foo bar'>foo1</span><span title='foo\nbar'>foo1</span></p>", 'html.parser')
print(*soup.select('span[title*="bar"]'))

I expected this to print both spans, but the actual output is

<span title="foo bar">foo1</span>

It seems that *= considers only the first line of multi-line attribute:

print(*soup.select('span[title*="foo"]'))

prints this:

<span title="foo bar">foo1</span> <span title="foo
bar">foo1</span>

Is there some bug, or some conscious limitation, or \n in attribute values is against the standard?
Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    S: confirmedConfirmed bug report or approved feature request.T: bugBug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions