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

find/2 input protection proposal. #497

Merged
merged 3 commits into from
Dec 11, 2023
Merged

find/2 input protection proposal. #497

merged 3 commits into from
Dec 11, 2023

Conversation

Hajto
Copy link
Contributor

@Hajto Hajto commented Oct 31, 2023

Today I had an issue where I accidentally passed {:ok, tree} into the find/2. I think it might not be a bad idea to protect the input with a guard. People who can't read the docs like me might save some frustration.

This is purely proposal. If I get a green light for this I will make develop this PR properly.

Copy link
Owner

@philss philss 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 it's a good idea. Please go ahead and try to fix the tests :)

lib/floki.ex Outdated Show resolved Hide resolved
@Hajto Hajto requested a review from philss November 6, 2023 21:23
@Hajto
Copy link
Contributor Author

Hajto commented Nov 6, 2023

Added:

  • Tests
    Fixed:
  • wrong doctype specification (it looks like it will never affect the find/2 guard but fixed for completenes)
  • moved list match out of guard definition since list is not valid node

@philss philss merged commit 7c4b68c into philss:main Dec 11, 2023
@philss
Copy link
Owner

philss commented Dec 11, 2023

@Hajto thank you! 💜

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

Successfully merging this pull request may close these issues.

2 participants