This commit is contained in:
Looly 2022-11-10 11:11:09 +08:00
parent 912c3e116d
commit 5bd54dcd39
3 changed files with 7 additions and 2 deletions

View File

@ -55,7 +55,6 @@ public class JarClassLoader extends URLClassLoader {
try {
final Method method = MethodUtil.getMethod(URLClassLoader.class, "addURL", URL.class);
if (null != method) {
method.setAccessible(true);
final List<File> jars = loopJar(jarFile);
for (final File jar : jars) {
MethodUtil.invoke(loader, method, jar.toURI().toURL());

View File

@ -308,6 +308,9 @@ public class XmlUtil {
// 3.得到解读器
reader = parse.getXMLReader();
// 防止XEE攻击https://www.jianshu.com/p/1a857905b22c
reader.setFeature("http://xml.org/sax/features/external-general-entities",false);
reader.setFeature("http://xml.org/sax/features/external-parameter-entities",false);
reader.setContentHandler(contentHandler);
reader.parse(source);
} catch (final ParserConfigurationException | SAXException e) {
@ -616,6 +619,8 @@ public class XmlUtil {
public static void transform(final Source source, final Result result, final String charset, final int indent, final boolean omitXmlDeclaration) {
final TransformerFactory factory = TransformerFactory.newInstance();
try {
// 防止XXE攻击https://www.jianshu.com/p/1a857905b22c
factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
final Transformer xformer = factory.newTransformer();
if (indent > 0) {
xformer.setOutputProperty(OutputKeys.INDENT, "yes");

View File

@ -213,8 +213,9 @@ class LZWEncoder {
if (free_ent < maxmaxcode) {
codetab[i] = free_ent++; // code -> hashtable
htab[i] = fcode;
} else
} else {
cl_block(outs);
}
}
// Put out the final code.
output(ent, outs);