-
Notifications
You must be signed in to change notification settings - Fork 38.3k
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
Spring fails to determine XML is XSD-based if DOCTYPE appears in a comment #27915
Comments
This is closely related to: Thanks for raising the issue. We'll look into it. |
The proposed change results in a |
Sorry, my carelessness caused I created 15 XML files and generated several random XML files using the program. These files even contain the following extreme cases: <!DOC<!-- comment -->TYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "https://www.springframework.org/dtd/spring-beans-2.0.dtd"> All files passed the test. I package and upload the modified code and these test files.I hope my method can solve this problem. |
Hi @shooye, Thanks for working on it and providing the ZIP file. I took a look at it, and it appears to fix the issue; however, I noticed that you introduced a second boolean flag to track whether we're "in a comment", and I thought we would still only need a single flag for that. In any case, the proper way to submit a fix is via a PR so that we can be sure you have signed the contributor agreement. If you have time to submit a PR, that would be great. Otherwise, I will likely attempt to fix the issue myself. Cheers, Sam |
Affects: 5.3.14 and earlier
If you want to load a DTD configuration file,
<! --
Different positions from-->
will affect the loading of spring.If my profile is written like this:
Then, when Spring is used to load the configuration file, an exception will appear.
This is because there is a bug when determining the profile validation pattern.
In
org.springframework.util.xml.XmlValidationModeDetector
,Spring analyzes programs one line at a time.However, each analysis focuses only on the first
<!--
in each line. Spring will put<!--
The previous content is not considered as a comment.Thus, the situation in the above example is ignored.
I think that can result in
org.springframework.util.xml.XmlValidationModeDetector#consumeCommentTokens(String line)
return to add the following code before:It can be removed in front of '-->'.
The text was updated successfully, but these errors were encountered: