Merge branch '7.0.x'

This commit is contained in:
Sam Brannen
2026-06-25 13:33:10 +02:00
5 changed files with 38 additions and 3 deletions
@@ -151,7 +151,9 @@ public class XmlValidationModeDetector {
private String consumeCommentTokens(String line) {
int indexOfStartComment = line.indexOf(START_COMMENT);
if (indexOfStartComment == -1 && !line.contains(END_COMMENT)) {
return line;
// If we are inside a multi-line comment, the entire line is comment
// data and must not be treated as content.
return (this.inComment ? "" : line);
}
String result = "";
@@ -44,7 +44,8 @@ class XmlValidationModeDetectorTests {
"dtdWithTrailingComment.xml",
"dtdWithTrailingCommentAcrossMultipleLines.xml",
"dtdWithCommentOnNextLine.xml",
"dtdWithMultipleComments.xml"
"dtdWithMultipleComments.xml",
"dtdWithDoctypeInMultiLineCommentBody.xml"
})
void dtdDetection(String fileName) throws Exception {
assertValidationMode(fileName, VALIDATION_DTD);
@@ -55,7 +56,9 @@ class XmlValidationModeDetectorTests {
"xsdWithNoComments.xml",
"xsdWithMultipleComments.xml",
"xsdWithDoctypeInComment.xml",
"xsdWithDoctypeInOpenCommentWithAdditionalCommentOnSameLine.xml"
"xsdWithDoctypeInOpenCommentWithAdditionalCommentOnSameLine.xml",
"xsdWithDoctypeInMultiLineCommentBody.xml",
"xsdWithMultipleDoctypesInMultiLineCommentBody.xml"
})
void xsdDetection(String fileName) throws Exception {
assertValidationMode(fileName, VALIDATION_XSD);
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
DOCTYPE
-->
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "https://www.springframework.org/dtd/spring-beans-2.0.dtd">
<beans>
</beans>
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
See the DOCTYPE notes for legacy configs
-->
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://www.springframework.org/schema/beans
https://www.springframework.org/schema/beans/spring-beans.xsd">
</beans>
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
xxx DOCTYPE xxx
yyy
zzz DOCTYPE zzz
-->
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://www.springframework.org/schema/beans
https://www.springframework.org/schema/beans/spring-beans.xsd">
</beans>