Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Entity bug #178

Open
ArthaTi opened this issue Dec 29, 2017 · 2 comments
Open

Entity bug #178

ArthaTi opened this issue Dec 29, 2017 · 2 comments

Comments

@ArthaTi
Copy link

ArthaTi commented Dec 29, 2017

That's my third issue in a row, sorry if that's annoying. I understand it's not easy to make such a library, I would help if I could...

Here's a simple script this issue occurs in:

p = pq("<span>&lt;foo&gt;&lt;bar&gt;</span>")
print(p("span").html(), p("span").text())
p = pq("<span><b>&lt;foo&gt;</b>&lt;bar&gt;</span>")
print(p("span").html(), p("span").text())

Output:

<foo><bar> <foo><bar>
<b>&lt;foo&gt;</b>&lt;bar&gt; <foo> <bar>

while it should be

&lt;foo&gt;&lt;bar&gt; <foo><bar>
<b>&lt;foo&gt;</b>&lt;bar&gt; <foo><bar>

Basically, if there are entities on the beginning and end of the selected element, then entities are decoded, even in HTML, when they shouldn't... Possible reason? Tried to search for it, but I really don't understand the code... Thanks.

@ArthaTi
Copy link
Author

ArthaTi commented Dec 29, 2017

Perhaps it's here:

if not children:
                return tag.text

tag.text is unencoded, while this function shouldn't return unencoded. Maybe just return it encoded?

I would fix it, but I don't see any function here for encoding/decoding entities in the project... how do I do it? I only know that there's one in html built-in library

@gawel
Copy link
Owner

gawel commented Dec 29, 2017

I guess there's no such thing because lxml do that

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

No branches or pull requests

2 participants