Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/main/java/com/ibatis/common/xml/NodeletParser.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2004-2024 the original author or authors.
* Copyright 2004-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -248,7 +248,6 @@ private Document createDocument(InputStream inputStream)
throws ParserConfigurationException, FactoryConfigurationError, SAXException, IOException {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
factory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
factory.setFeature("http://xml.org/sax/features/external-general-entities", false);
factory.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
factory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Copyright 2004-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.ibatis.sqlmap.engine.builder.xml;

import com.ibatis.common.resources.Resources;

import java.io.IOException;
import java.io.InputStreamReader;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

class SqlMapConfigParserTest {
@Test
void parseStream() throws IOException {
SqlMapConfigParser parser = new SqlMapConfigParser();
var stream = Resources.getResourceAsStream("com/ibatis/sqlmap/maps/SqlMapConfig.xml");
final var sqlMapClient = parser.parse(stream); // fails

Assertions.assertNotNull(sqlMapClient);
}

@Test
void parseStreamToReader() throws IOException {
SqlMapConfigParser parser = new SqlMapConfigParser();
var stream = Resources.getResourceAsStream("com/ibatis/sqlmap/maps/SqlMapConfig.xml");
var reader = new InputStreamReader(stream);
final var sqlMapClient = parser.parse(reader);

Assertions.assertNotNull(sqlMapClient);
}

@Test
void parseReader() throws IOException {
SqlMapConfigParser parser = new SqlMapConfigParser();
var reader = Resources.getResourceAsReader("com/ibatis/sqlmap/maps/SqlMapConfig.xml");
final var sqlMapClient = parser.parse(reader);

Assertions.assertNotNull(sqlMapClient);
}
}
Loading