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

parse & parseNoneClosedTags invalid behaviour #231

Open
bujhmt opened this issue Dec 8, 2022 · 1 comment
Open

parse & parseNoneClosedTags invalid behaviour #231

bujhmt opened this issue Dec 8, 2022 · 1 comment

Comments

@bujhmt
Copy link

bujhmt commented Dec 8, 2022

Hello, @taoqf! parseNoneClosedTags property doesn't work properly.

Wrong html fragment:

<div>
    <ul>
        <li>
            <a href="https://example.com">1</a>
            <span class="cat-count-span">(1)
        </li>
        <li><a href="https://example.com">2</a><span class="cat-count-span">(1)</li>
        <li><a href="https://example.com">3</a><span class="cat-count-span">(1)</li>
        <li><a href="https://example.com">4</a><span class="cat-count-span">(1)</li>
        <li><a href="https://example.com">5</a><span class="cat-count-span">(1)</li>
        <li><a href="https://example.com">6</a><span class="cat-count-span">(1)</li>
        <li><a href="https://example.com">7</a><span class="cat-count-span">(1)</li>
        <li><a href="https://example.com">8</a><span class="cat-count-span">(1)</li>
    </ul>
</div>

Browser fixed output (from devtools):

...
    <li>
        <a href="https://example.com">1</a>
        <span class="cat-count-span">(1)</span>
    </li>
...
const output = parse(html, {comment: false, parseNoneClosedTags: true})

Library output:

<div>
    <ul>
        <li>
            <a href="https://example.com">1</a>
            <span class="cat-count-span">(1)

        <li><a href="https://example.com">2</a><span class="cat-count-span">(1)
        <li><a href="https://example.com">3</a><span class="cat-count-span">(1)
        <li><a href="https://example.com">4</a><span class="cat-count-span">(1)
        <li><a href="https://example.com">5</a><span class="cat-count-span">(1)
        <li><a href="https://example.com">6</a><span class="cat-count-span">(1)
        <li><a href="https://example.com">7</a><span class="cat-count-span">(1)
        <li><a href="https://example.com">8</a><span class="cat-count-span">(1)
</span></li>
        </span></li></span></li></span></li></span></li></span></li></span></li></span></li></ul>
</div>

On the other hand, if I parse large html with this "span issue" and use parse without parseNoneClosedTags property, I will get infinite loop inside library.

@bujhmt bujhmt changed the title parseNoneClosedTags invalid behaviour parse & parseNoneClosedTags invalid behaviour Dec 8, 2022
@taoqf taoqf added the bug label Dec 9, 2022
@taoqf
Copy link
Owner

taoqf commented Aug 17, 2023

#152

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

No branches or pull requests

2 participants