philss / floki

Floki is a simple HTML parser that enables search for nodes using CSS selectors.
https://hex.pm/packages/floki
MIT License
2.05k stars 155 forks source link

Bug: attribute values can no longer be iodata lists #188

Closed katehedgpeth closed 6 years ago

katehedgpeth commented 6 years ago

Hi and thanks for this great tool! It's been a big help for us in parsing and incorporating content from our CMS into our phoenix site.

We've recently attempted to upgrade to 0.20.3 and realized that there's a breaking change in a recent commit: https://github.com/philss/floki/commit/c5eb4fddc143c2dd784767e3d1fa5b17acf8df01#diff-89b5940fb49d7d4e900ac542fea22545R87

The above commit checks attribute values for double quotes, but doesn't first ensure that the value is a string. We have some attributes that we build as iodata lists, which has always worked fine until this change.

I'd like to propose adding some guards to this function, and calling IO.iodata_to_binary first if the value is a list. I have a PR-ready implementation if this sounds like a change you would like to make; or if there is a better solution, I'd be happy to give it a shot.

philss commented 6 years ago

Hi @katehedgpeth! Thank you! And also thank you for open the issue.

Sorry for the delay. It would be great if you open a PR with this fix! 😄 Please add a test case for this if possible.

katehedgpeth commented 6 years ago

@philss PR submitted!

philss commented 6 years ago

@katehedgpeth this fix is now available on v0.20.4.