Skip to content

Commit

Permalink
fix: implement accessor for SAX external-general-entities feature
Browse files Browse the repository at this point in the history
  • Loading branch information
cjmamo committed Mar 18, 2021
1 parent 8658e91 commit c55292f
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ public boolean getFeature(String name)
switch (stdFeat) {
case IS_STANDALONE: // read-only, but only during parsing
return true;
case EXTERNAL_GENERAL_ENTITIES:
return ((Boolean) mStaxFactory.getProperty(ReaderConfig.EXPAND_GENERAL_ENTITIES)).booleanValue();
default:
}
} else {
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/fasterxml/aalto/sax/SAXParserImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,8 @@ public boolean getFeature(String name)
case IS_STANDALONE: // read-only, but only during parsing
// !!! TBI
return true;
case EXTERNAL_GENERAL_ENTITIES:
return ((Boolean) _staxFactory.getProperty(ReaderConfig.EXPAND_GENERAL_ENTITIES)).booleanValue();
default:
}
} else {
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/com/fasterxml/aalto/sax/SAXUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ public static SAXProperty findStdProperty(String featURI)
public static Boolean getFixedStdFeatureValue(SAXFeature stdFeat)
{
switch (stdFeat) {
case EXTERNAL_GENERAL_ENTITIES: // not yet implemented
return Boolean.FALSE;
case EXTERNAL_PARAMETER_ENTITIES: // not yet implemented
return Boolean.FALSE;
case IS_STANDALONE: // read-only, but only during parsing
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.fasterxml.aalto.sax;

import org.xml.sax.SAXNotRecognizedException;
import org.xml.sax.SAXNotSupportedException;

public class TestSAXParserFactoryImpl extends base.BaseTestCase {

public void testSetGetFeatureExternalGeneralEntities() throws SAXNotRecognizedException, SAXNotSupportedException {
SAXParserFactoryImpl saxParserFactory = new SAXParserFactoryImpl();
saxParserFactory.setFeature("http://xml.org/sax/features/external-general-entities", false);
assertFalse(saxParserFactory.getFeature("http://xml.org/sax/features/external-general-entities"));

saxParserFactory.setFeature("http://xml.org/sax/features/external-general-entities", true);
assertTrue(saxParserFactory.getFeature("http://xml.org/sax/features/external-general-entities"));
}

}

0 comments on commit c55292f

Please sign in to comment.