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

fix: typecheck source param before parsing #113

Merged
merged 1 commit into from Aug 26, 2020
Merged

Conversation

jesse-y
Copy link
Contributor

@jesse-y jesse-y commented Aug 25, 2020

Updates DOMParser.parseFromString to also check that the source provided is a string. To prevent sax from throwing undefined errors when calling indexOf on the source.

Adds unit tests to test/parse/simple.vows.js to cover this edge case.

Resolves #98

@brodybits
Copy link
Member

Resolution looks OK to me, thanks.

We may rework the test cases in the future, as discussed in #71. But I think we may as well merge now to resolve the issue. Any comments from @karfau?

@jesse-y
Copy link
Contributor Author

jesse-y commented Aug 25, 2020

Yeah, I'd be fine with these tests being rewritten in another framework (I'm more familiar with Jest, so it's a +1 for me in regard to #72 ). Also happy to help on that front when some of the other housekeeping PRs (#102 #110 ) are in.

Copy link
Member

@karfau karfau left a comment

Choose a reason for hiding this comment

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

Sorry for the delay, go for it!

@brodybits brodybits merged commit bd81fab into xmldom:master Aug 26, 2020
This was referenced Mar 9, 2021
This was referenced Mar 13, 2021
@karfau
Copy link
Member

karfau commented Oct 31, 2022

FYI: 0.9.0 will change this:
In case of XML parsing to be a fatalError, which causes DOMParser.parseFromString to throw in such a case.
(This change helps to avoid the situation, in which undefined is returned instead of a Document.)
In case of HTML parsing it will not be reported as any kind of error, since browsers also support passing arbitrary values, that are String()ified before being added to the body.

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.

Infinite-loop error
3 participants