Skip to content
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

#802 Check TransformerFactory feature values before attempting to set them #803

Open
wants to merge 1 commit into
base: open-dev-v1
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,13 @@ private void setDocumentBuilderSecurityFeatures(DocumentBuilderFactory dbf) {
private void setTranformerFactorySecurityFeatures(TransformerFactory xformFactory) {
boolean b = true;

b &= trySetFeature(XMLConstants.ACCESS_EXTERNAL_DTD, "", xformFactory::setAttribute);
b &= trySetFeature(XMLConstants.ACCESS_EXTERNAL_STYLESHEET, "", xformFactory::setAttribute);
boolean isAccessExternalDtdFeature = xformFactory.getFeature(XMLConstants.ACCESS_EXTERNAL_DTD);
boolean isAccessExternalStylesheet = xformFactory.getFeature(XMLConstants.ACCESS_EXTERNAL_STYLESHEET);
boolean isFeatureSecureProcessing = xformFactory.getFeature(XMLConstants.FEATURE_SECURE_PROCESSING);

b &= (isAccessExternalDtdFeature ? trySetFeature(XMLConstants.ACCESS_EXTERNAL_DTD, "", xformFactory::setAttribute) : true);
b &= (isAccessExternalStylesheet ? trySetFeature(XMLConstants.ACCESS_EXTERNAL_STYLESHEET, "", xformFactory::setAttribute) : true);
b &= (isFeatureSecureProcessing ? trySetFeature(XMLConstants.FEATURE_SECURE_PROCESSING, "", xformFactory::setAttribute) : true);

if (!b) {
XRLog.log(Level.SEVERE, LogMessageId.LogMessageId0Param.LOAD_UNABLE_TO_DISABLE_XML_EXTERNAL_ENTITIES);
Expand Down