< prev index next >

src/java.xml/share/classes/com/sun/org/apache/xml/internal/utils/XMLReaderManager.java

Print this page
rev 1063 : 8172974: [JAXP] XALAN: Wrong result when transforming namespace unaware StAX Input

*** 1,7 **** /* ! * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. --- 1,7 ---- /* ! * Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership.
*** 48,59 **** private static final String NAMESPACES_FEATURE = "http://xml.org/sax/features/namespaces"; private static final String NAMESPACE_PREFIXES_FEATURE = "http://xml.org/sax/features/namespace-prefixes"; private static final XMLReaderManager m_singletonManager = ! new XMLReaderManager(); private static final String property = "org.xml.sax.driver"; /** * Parser factory to be used to construct XMLReader objects */ private static SAXParserFactory m_parserFactory; --- 48,60 ---- private static final String NAMESPACES_FEATURE = "http://xml.org/sax/features/namespaces"; private static final String NAMESPACE_PREFIXES_FEATURE = "http://xml.org/sax/features/namespace-prefixes"; private static final XMLReaderManager m_singletonManager = ! new XMLReaderManager(); private static final String property = "org.xml.sax.driver"; + /** * Parser factory to be used to construct XMLReader objects */ private static SAXParserFactory m_parserFactory;
*** 68,95 **** private HashMap<XMLReader, Boolean> m_inUse; private boolean m_useServicesMechanism = true; private boolean _secureProcessing; ! /** * protocols allowed for external DTD references in source file and/or stylesheet. */ private String _accessExternalDTD = XalanConstants.EXTERNAL_ACCESS_DEFAULT; private XMLSecurityManager _xmlSecurityManager; ! //Catalog Feature private boolean _useCatalog; private CatalogFeatures _catalogFeatures; private int _cdataChunkSize; /** * Hidden constructor */ ! private XMLReaderManager() { ! } /** * Retrieves the singleton reader manager */ public static XMLReaderManager getInstance(boolean useServicesMechanism) { --- 69,98 ---- private HashMap<XMLReader, Boolean> m_inUse; private boolean m_useServicesMechanism = true; private boolean _secureProcessing; ! ! /** * protocols allowed for external DTD references in source file and/or stylesheet. */ private String _accessExternalDTD = XalanConstants.EXTERNAL_ACCESS_DEFAULT; private XMLSecurityManager _xmlSecurityManager; ! /** ! * Catalog Feature ! */ private boolean _useCatalog; private CatalogFeatures _catalogFeatures; private int _cdataChunkSize; /** * Hidden constructor */ ! private XMLReaderManager() {} /** * Retrieves the singleton reader manager */ public static XMLReaderManager getInstance(boolean useServicesMechanism) {
*** 120,131 **** // one; otherwise, return the cached reader unless it isn't an // instance of the class set in the 'org.xml.sax.driver' property reader = m_readers.get(); boolean threadHasReader = (reader != null); String factory = SecuritySupport.getSystemProperty(property); ! if (threadHasReader && m_inUse.get(reader) != Boolean.TRUE && ! ( factory == null || reader.getClass().getName().equals(factory))) { m_inUse.put(reader, Boolean.TRUE); } else { try { try { // According to JAXP 1.2 specification, if a SAXSource --- 123,135 ---- // one; otherwise, return the cached reader unless it isn't an // instance of the class set in the 'org.xml.sax.driver' property reader = m_readers.get(); boolean threadHasReader = (reader != null); String factory = SecuritySupport.getSystemProperty(property); ! if (threadHasReader && ! m_inUse.get(reader) != Boolean.TRUE && ! (factory == null || reader.getClass().getName().equals(factory))) { m_inUse.put(reader, Boolean.TRUE); } else { try { try { // According to JAXP 1.2 specification, if a SAXSource
*** 174,196 **** m_inUse.put(reader, Boolean.TRUE); } } //reader is cached, but this property might have been reset ! JdkXmlUtils.setXMLReaderPropertyIfSupport(reader, XMLConstants.ACCESS_EXTERNAL_DTD, ! _accessExternalDTD, true); ! JdkXmlUtils.setXMLReaderPropertyIfSupport(reader, JdkXmlUtils.CDATA_CHUNK_SIZE, ! _cdataChunkSize, false); String lastProperty = ""; try { if (_xmlSecurityManager != null) { for (XMLSecurityManager.Limit limit : XMLSecurityManager.Limit.values()) { lastProperty = limit.apiProperty(); reader.setProperty(lastProperty, ! _xmlSecurityManager.getLimitValueAsString(limit)); } if (_xmlSecurityManager.printEntityCountInfo()) { lastProperty = XalanConstants.JDK_ENTITY_COUNT_INFO; reader.setProperty(XalanConstants.JDK_ENTITY_COUNT_INFO, XalanConstants.JDK_YES); } --- 178,200 ---- m_inUse.put(reader, Boolean.TRUE); } } //reader is cached, but this property might have been reset ! JdkXmlUtils.setXMLReaderPropertyIfSupport(reader, ! XMLConstants.ACCESS_EXTERNAL_DTD, _accessExternalDTD, true); ! JdkXmlUtils.setXMLReaderPropertyIfSupport(reader, ! JdkXmlUtils.CDATA_CHUNK_SIZE, _cdataChunkSize, false); String lastProperty = ""; try { if (_xmlSecurityManager != null) { for (XMLSecurityManager.Limit limit : XMLSecurityManager.Limit.values()) { lastProperty = limit.apiProperty(); reader.setProperty(lastProperty, ! _xmlSecurityManager.getLimitValueAsString(limit)); } if (_xmlSecurityManager.printEntityCountInfo()) { lastProperty = XalanConstants.JDK_ENTITY_COUNT_INFO; reader.setProperty(XalanConstants.JDK_ENTITY_COUNT_INFO, XalanConstants.JDK_YES); }
*** 200,211 **** } boolean supportCatalog = true; try { reader.setFeature(JdkXmlUtils.USE_CATALOG, _useCatalog); ! } ! catch (SAXNotRecognizedException | SAXNotSupportedException e) { supportCatalog = false; } if (supportCatalog && _useCatalog && _catalogFeatures != null) { try { --- 204,214 ---- } boolean supportCatalog = true; try { reader.setFeature(JdkXmlUtils.USE_CATALOG, _useCatalog); ! } catch (SAXNotRecognizedException | SAXNotSupportedException e) { supportCatalog = false; } if (supportCatalog && _useCatalog && _catalogFeatures != null) { try {
*** 248,258 **** /** * Set feature */ public void setFeature(String name, boolean value) { ! if (name.equals(XMLConstants.FEATURE_SECURE_PROCESSING)) { _secureProcessing = value; } else if (XMLConstants.USE_CATALOG.equals(name)) { _useCatalog = value; } } --- 251,261 ---- /** * Set feature */ public void setFeature(String name, boolean value) { ! if (XMLConstants.FEATURE_SECURE_PROCESSING.equals(name)) { _secureProcessing = value; } else if (XMLConstants.USE_CATALOG.equals(name)) { _useCatalog = value; } }
< prev index next >