-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Karate (Thymeleaf -> SAXParser) prints "Fatal Error" when encountering valid HTML5 #1684
Comments
yes a
you are welcome to improve the error message and submit a PR ! BTW you can also add this line to your test: * assert responseType == 'string' and since you seem to trying to scrape things out of HTML see this also: https://stackoverflow.com/a/67331307/143475 |
actually on second thoughts can @edwardsph comment on this related to #1462 it does make sense that we only convert to XML based on the response content-type. I just worry about existing tests in the wild as always (especially a lot of SOAP users). and if there are more "exotic" content-types that happen to be just XML |
I think it should detect that the content-type is neither JSON, XML nor plain text and therefore not attempt to SAX parse it but I will have a closer look next week. |
@edwardsph okay I took care of it and the diff is interesting. I think it will be fine, but anyway we will do RC5 to see what the feedback is @bnutzer you convinced us :) reopening - and do let me know if the fix works ! |
@ptrthomas Perfect! Works for me, fixes both the sample request as well as my production code. Thanks for your hint for the karate.extract() function. Probably a valuable solution for lots of cases. However, in my case I need to collect all "name" attributes of all html entities with a certain "class" attribute. That's 3 lines of well readable code using Java, but would be hell of a regex using the "extract" function, I suppose. The diff looks straight forward and really sensible to me. However, I do understand that this might be breaking for some folks. Thanks again! |
@bnutzer I'll keep this open until the "final" version, that's what we usually do with especially (potentially) breaking issues like this one P.S. thanks for starring the project - you made it into the screenshot: https://twitter.com/KarateDSL/status/1416013547067248640 |
1.1.0 released |
Please re-open. See PR #1705 |
I am attempting to use Karate to authenticate with our service via an OAuth2 authorization code grant. During the process, my test needs to fetch (and parse, using JSoup in a Java interop) our service's scope approval web page. This page is valid HTML5 (hopefully), containing unclosed
<link>
and<meta>
tags.As far as I can tell, karate attempts to parse that page through thymeleaf, which, in turn seems to attempt to use a SAXParser to process. That results in an error message "Fatal Error" in the logs (although the test then continues and succeeds).
I am attaching a trivial feature file
html5-fetch.feature.txt
to fetch from a stub from a web site of mine.
Unfortunately, I seem to be unable to produce an English error message; the German equivalent is
(seems to translate to
org.xml.sax.SAXParseException: Element type "link" must be terminated by a matching end tag "</link>"
)I would prefer not having "Fatal Errors" in my test logs, even when they succeed. It does not seem to be a good idea to attempt to parse responses as xml, unless the content type is xml.
I am fine if you regard this topic as a non-issue :)
The text was updated successfully, but these errors were encountered: