git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@1222724 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -17,7 +17,8 @@ Fixed bugs: | |||||
| Bugzilla Report 51049. | Bugzilla Report 51049. | ||||
| * <junitreport> did not work in embedded environments on JDK 7. | * <junitreport> did not work in embedded environments on JDK 7. | ||||
| Bugzilla Report 51668. | |||||
| Nor did <xslt> when using Xalan redirects. | |||||
| Bugzilla Report 51668, 52382. | |||||
| * Encoding of unicode escape sequences by the property file task | * Encoding of unicode escape sequences by the property file task | ||||
| Bugzilla Report 50515. | Bugzilla Report 50515. | ||||
| @@ -419,12 +419,12 @@ public class TraXLiaison implements XSLTLiaison3, ErrorListener, XSLTLoggerAware | |||||
| } | } | ||||
| } | } | ||||
| if (Boolean.TRUE.equals(DISABLE_SECURE_PROCESSING.get())) { | |||||
| try { | |||||
| Field _isNotSecureProcessing = tfactory.getClass().getDeclaredField("_isNotSecureProcessing"); | |||||
| _isNotSecureProcessing.setAccessible(true); | |||||
| _isNotSecureProcessing.set(tfactory, Boolean.TRUE); | |||||
| } catch (Exception x) { | |||||
| try { // #51668, #52382 | |||||
| Field _isNotSecureProcessing = tfactory.getClass().getDeclaredField("_isNotSecureProcessing"); | |||||
| _isNotSecureProcessing.setAccessible(true); | |||||
| _isNotSecureProcessing.set(tfactory, Boolean.TRUE); | |||||
| } catch (Exception x) { | |||||
| if (project != null) { | |||||
| project.log(x.toString(), Project.MSG_DEBUG); | project.log(x.toString(), Project.MSG_DEBUG); | ||||
| } | } | ||||
| } | } | ||||
| @@ -443,11 +443,6 @@ public class TraXLiaison implements XSLTLiaison3, ErrorListener, XSLTLoggerAware | |||||
| } | } | ||||
| return tfactory; | return tfactory; | ||||
| } | } | ||||
| /** | |||||
| * Not part of any stable API. | |||||
| * @see #51668 | |||||
| */ | |||||
| public static final ThreadLocal/*<Boolean>*/ DISABLE_SECURE_PROCESSING = new ThreadLocal(); | |||||
| /** | /** | ||||
| @@ -261,13 +261,10 @@ public class AggregateTransformer { | |||||
| paramx.setName("output.dir"); | paramx.setName("output.dir"); | ||||
| paramx.setExpression(toDir.getAbsolutePath()); | paramx.setExpression(toDir.getAbsolutePath()); | ||||
| final long t0 = System.currentTimeMillis(); | final long t0 = System.currentTimeMillis(); | ||||
| TraXLiaison.DISABLE_SECURE_PROCESSING.set(Boolean.TRUE); | |||||
| try { | try { | ||||
| xsltTask.execute(); | xsltTask.execute(); | ||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| throw new BuildException("Errors while applying transformations: " + e.getMessage(), e); | throw new BuildException("Errors while applying transformations: " + e.getMessage(), e); | ||||
| } finally { | |||||
| TraXLiaison.DISABLE_SECURE_PROCESSING.set(null); | |||||
| } | } | ||||
| final long dt = System.currentTimeMillis() - t0; | final long dt = System.currentTimeMillis() - t0; | ||||
| task.log("Transform time: " + dt + "ms"); | task.log("Transform time: " + dt + "ms"); | ||||
| @@ -5,7 +5,10 @@ import org.apache.tools.ant.taskdefs.XSLTLogger; | |||||
| import org.apache.tools.ant.BuildException; | import org.apache.tools.ant.BuildException; | ||||
| import org.apache.tools.ant.util.JAXPUtils; | import org.apache.tools.ant.util.JAXPUtils; | ||||
| import java.io.ByteArrayInputStream; | |||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.InputStream; | |||||
| import java.security.Permission; | |||||
| import junit.framework.AssertionFailedError; | import junit.framework.AssertionFailedError; | ||||
| @@ -65,11 +68,26 @@ public class TraXLiaisonTest extends AbstractXSLTLiaisonTest | |||||
| liaison.setStylesheet(xsl); | liaison.setStylesheet(xsl); | ||||
| File out = new File("xalan2-redirect-out-dummy.tmp"); | File out = new File("xalan2-redirect-out-dummy.tmp"); | ||||
| File in = getFile("/taskdefs/optional/xsltliaison-in.xsl"); | File in = getFile("/taskdefs/optional/xsltliaison-in.xsl"); | ||||
| ClassLoader orig = Thread.currentThread().getContextClassLoader(); | |||||
| try { | try { | ||||
| liaison.addParam("xalan-version", "2"); | liaison.addParam("xalan-version", "2"); | ||||
| // Use the JRE's Xerces, not lib/optional/xerces.jar: | |||||
| Thread.currentThread().setContextClassLoader(new ClassLoader(ClassLoader.getSystemClassLoader().getParent()) { | |||||
| public InputStream getResourceAsStream(String name) { | |||||
| if (name.startsWith("META-INF/services/")) { | |||||
| // work around JAXP #6723276 in JDK 6 | |||||
| return new ByteArrayInputStream(new byte[0]); | |||||
| } | |||||
| return super.getResourceAsStream(name); | |||||
| } | |||||
| }); | |||||
| // Tickle #52382: | |||||
| System.setSecurityManager(new SecurityManager() {public void checkPermission(Permission perm) {}}); | |||||
| liaison.transform(in, out); | liaison.transform(in, out); | ||||
| } finally { | } finally { | ||||
| out.delete(); | out.delete(); | ||||
| Thread.currentThread().setContextClassLoader(orig); | |||||
| System.setSecurityManager(null); | |||||
| } | } | ||||
| } | } | ||||