Input Validation #578
jugglinmike
started this conversation in
Ideas
Replies: 1 comment
-
Having this baked in Cheerio would be awesome, as now we face the issue that we need to validate user input first before sending to Cheerio. For example this invalid input:
will return invalid HTML with Cheerio. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
In gh-574, @davidchambers suggested some ideas for refactoring Cheerio's internal
isHTML
(see below). In the process, we recognized that Cheerio differs from jQuery in the types of strings it accepts in the constructor function, and how it behaves on invalid input.Input interpretation
For any given string input, both libraries have to decide how it should be interpreted (as HTML or as a CSS selector) and then either accept the string or reject it. The libraries differ in how they make this decision and how accepting they are when accepted either type (Cheerio seems to be generally more lax).
Response to invalid input
Sizzle.js (and therefor jQuery) throws an error in response to invalid input, eg:
Cheerio, on the other hand, returns an empty collection and currently has a test to assert this behavior.
The questions I'd like to address with this issue are:
From @davidchambers in gh-574:
..and:
Beta Was this translation helpful? Give feedback.
All reactions