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

Another case of bad markup identified in Issue#549. Closing tags without having opening tags. Test cases also added. #568

Merged
merged 3 commits into from
Sep 12, 2022

Conversation

kedarchandrayan
Copy link
Contributor

Summary

Closes #549

What are the specific steps to test this change?

The snippets given in the issues should now work as expected.

What kind of change does this PR introduce?

(Check at least one)

  • Bug fix
  • New feature
  • Refactor
  • Documentation
  • Build-related changes
  • Other

Make sure the PR fulfills these requirements:

  • It includes a) the existing issue ID being resolved, b) a convincing reason for adding this feature, or c) a clear description of the bug it resolves
  • The changelog is updated
  • Related documentation has been updated
  • Related tests have been updated

If adding a new feature without an already open issue, it's best to open a feature request issue first and wait for approval before working on it.

Other information:

@kedarchandrayan
Copy link
Contributor Author

kedarchandrayan commented Sep 5, 2022

Hello Team,
cc: @boutell

Please review this change and let me know your comments.

Thanks in advance!
Kedar Chandrayan

Copy link
Member

@boutell boutell left a comment

Choose a reason for hiding this comment

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

I think the current code tolerates markup like this:

<div>
<p>
<p>
<p>
</div>

I think your change would break that which is too strict (a backwards compatibility break). Please add unit tests confirming if you think it won't be a problem.

Also:

<div>
<br />
<br />
<br />
</div>

I'm not sure if these self-closing tags go on the stack or not.

…rtant backward compatibility check for future changes.
@kedarchandrayan
Copy link
Contributor Author

kedarchandrayan commented Sep 12, 2022

Hello @boutell,

Thank you for the feedback. Following is my response, point-wise.

Markup like the following works fine, even after the change. htmlparser2 gives callbacks for both onopentag and onclosetag for the p tags, even if the closing p tags are not present.

<div>
<p>
<p>
<p>
</div>

I have added 2 test cases for the above markup as asked by you.

For self-closing tags, htmlparser2 gives consecutive callbacks for onopentag and onclosetag. For these, the tag goes in the stack and gets popped immediately. So these will also work with the change made.

Please let me know if anything else is needed from my end.

Thanks,
Kedar Chandrayan

@boutell boutell merged commit 6b76815 into apostrophecms:main Sep 12, 2022
@boutell
Copy link
Member

boutell commented Sep 12, 2022

Thanks!

@kedarchandrayan
Copy link
Contributor Author

Thank you @boutell 🙏

@kedarchandrayan kedarchandrayan deleted the develop branch September 16, 2022 07:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants