You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@freemarker.apache.org by dd...@apache.org on 2017/01/21 14:01:28 UTC
incubator-freemarker git commit: Removed utility TemplateModel-s that
can very easily mean a security problem: freemarker.template.utility.Execute
and freemarker.template.utility.ObjectConstructor
Repository: incubator-freemarker
Updated Branches:
refs/heads/3 4cbc134e5 -> 88d1d901b
Removed utility TemplateModel-s that can very easily mean a security problem: freemarker.template.utility.Execute and freemarker.template.utility.ObjectConstructor
Project: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/commit/88d1d901
Tree: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/tree/88d1d901
Diff: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/diff/88d1d901
Branch: refs/heads/3
Commit: 88d1d901b79dffbe78740ae2d99982c78cfc4343
Parents: 4cbc134
Author: ddekany <dd...@apache.org>
Authored: Sat Jan 21 14:59:55 2017 +0100
Committer: ddekany <dd...@apache.org>
Committed: Sat Jan 21 14:59:55 2017 +0100
----------------------------------------------------------------------
src/main/java/freemarker/core/Configurable.java | 2 +
.../freemarker/core/TemplateClassResolver.java | 25 +----
.../freemarker/template/utility/Execute.java | 104 -------------------
.../template/utility/ObjectConstructor.java | 57 ----------
src/manual/en_US/FM3-CHANGE-LOG.txt | 6 +-
.../core/OptInTemplateClassResolverTest.java | 32 +++---
.../expected/new-defaultresolver.txt | 1 -
.../test/templatesuite/expected/new-safer.txt | 20 ----
.../templatesuite/expected/new-unrestricted.txt | 20 ----
.../templates/new-allowsnothing.ftl | 23 ----
.../templates/new-defaultresolver.ftl | 3 +-
.../test/templatesuite/templates/new-safer.ftl | 24 -----
.../templates/new-unrestricted.ftl | 20 ----
.../freemarker/test/templatesuite/testcases.xml | 6 +-
14 files changed, 27 insertions(+), 316 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/88d1d901/src/main/java/freemarker/core/Configurable.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/Configurable.java b/src/main/java/freemarker/core/Configurable.java
index 748956f..8e35b5b 100644
--- a/src/main/java/freemarker/core/Configurable.java
+++ b/src/main/java/freemarker/core/Configurable.java
@@ -1367,6 +1367,8 @@ public class Configurable {
* Retrieves the {@link TemplateClassResolver} used
* to resolve classes when "SomeClassName"?new is called in a template.
*
+ * @see #setNewBuiltinClassResolver(TemplateClassResolver)
+ *
* @since 2.3.17
*/
public TemplateClassResolver getNewBuiltinClassResolver() {
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/88d1d901/src/main/java/freemarker/core/TemplateClassResolver.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/TemplateClassResolver.java b/src/main/java/freemarker/core/TemplateClassResolver.java
index 80da24f..bacc311 100644
--- a/src/main/java/freemarker/core/TemplateClassResolver.java
+++ b/src/main/java/freemarker/core/TemplateClassResolver.java
@@ -22,8 +22,6 @@ package freemarker.core;
import freemarker.template.Template;
import freemarker.template.TemplateException;
import freemarker.template.utility.ClassUtil;
-import freemarker.template.utility.Execute;
-import freemarker.template.utility.ObjectConstructor;
/**
* Used by built-ins and other template language features that get a class
@@ -44,6 +42,7 @@ public interface TemplateClassResolver {
*/
TemplateClassResolver UNRESTRICTED_RESOLVER = new TemplateClassResolver() {
+ @Override
public Class resolve(String className, Environment env, Template template)
throws TemplateException {
try {
@@ -56,31 +55,17 @@ public interface TemplateClassResolver {
};
/**
- * Same as {@link #UNRESTRICTED_RESOLVER}, except that it doesn't allow
- * resolving {@link ObjectConstructor} and {@link Execute}.
+ * Same as {@link #UNRESTRICTED_RESOLVER} at the moment.
*/
- TemplateClassResolver SAFER_RESOLVER = new TemplateClassResolver() {
-
- public Class resolve(String className, Environment env, Template template)
- throws TemplateException {
- if (className.equals(ObjectConstructor.class.getName())
- || className.equals(Execute.class.getName())) {
- throw MessageUtil.newInstantiatingClassNotAllowedException(className, env);
- }
- try {
- return ClassUtil.forName(className);
- } catch (ClassNotFoundException e) {
- throw new _MiscTemplateException(e, env);
- }
- }
-
- };
+ // [FM3] Do something with this. Like, only classes annotated in a certain would be accessible.
+ TemplateClassResolver SAFER_RESOLVER = UNRESTRICTED_RESOLVER;
/**
* Doesn't allow resolving any classes.
*/
TemplateClassResolver ALLOWS_NOTHING_RESOLVER = new TemplateClassResolver() {
+ @Override
public Class resolve(String className, Environment env, Template template)
throws TemplateException {
throw MessageUtil.newInstantiatingClassNotAllowedException(className, env);
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/88d1d901/src/main/java/freemarker/template/utility/Execute.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/template/utility/Execute.java b/src/main/java/freemarker/template/utility/Execute.java
deleted file mode 100644
index b122500..0000000
--- a/src/main/java/freemarker/template/utility/Execute.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * 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. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package freemarker.template.utility;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.util.List;
-
-import freemarker.template.TemplateModelException;
-
-/**
- * <p>Gives FreeMarker the the ability to execute external commands. Will fork
- * a process, and inline anything that process sends to stdout in the template.
- * Based on a patch submitted by Peter Molettiere.</p>
- *
- * <p>BE CAREFUL! this tag, depending on use, may allow you
- * to set something up so that users of your web
- * application could run arbitrary code on your server.
- * This can only happen if you allow unchecked GET/POST
- * submissions to be used as the command string in the
- * exec tag.</p>
- *
- * <p>Usage:<br>
- * From java:</p>
- * <pre>
- * SimpleHash root = new SimpleHash();
- *
- * root.put( "exec", new freemarker.template.utility.Execute() );
- *
- * ...
- * </pre>
- *
- * <p>From your FreeMarker template:</p>
- * <pre>
- *
- * The following is executed:
- * ${exec( "/usr/bin/ls" )}
- *
- * ...
- * </pre>
- */
-public class Execute implements freemarker.template.TemplateMethodModel {
-
- private final static int OUTPUT_BUFFER_SIZE = 1024;
-
- /**
- * Executes a method call.
- *
- * @param arguments a <tt>List</tt> of <tt>String</tt> objects containing the values
- * of the arguments passed to the method.
- * @return the <tt>TemplateModel</tt> produced by the method, or null.
- */
- public Object exec (List arguments) throws TemplateModelException {
- String aExecute;
- StringBuilder aOutputBuffer = new StringBuilder();
-
- if ( arguments.size() < 1 ) {
- throw new TemplateModelException( "Need an argument to execute" );
- }
-
- aExecute = (String) (arguments.get(0));
-
- try {
- Process exec = Runtime.getRuntime().exec( aExecute );
-
- // stdout from the process comes in here
- InputStream execOut = exec.getInputStream();
- try {
- Reader execReader = new InputStreamReader( execOut );
-
- char[] buffer = new char[ OUTPUT_BUFFER_SIZE ];
- int bytes_read = execReader.read( buffer );
- while ( bytes_read > 0 ) {
- aOutputBuffer.append( buffer, 0, bytes_read );
- bytes_read = execReader.read( buffer );
- }
- } finally {
- execOut.close();
- }
- } catch ( IOException ioe ) {
- throw new TemplateModelException( ioe.getMessage() );
- }
- return aOutputBuffer.toString();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/88d1d901/src/main/java/freemarker/template/utility/ObjectConstructor.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/template/utility/ObjectConstructor.java b/src/main/java/freemarker/template/utility/ObjectConstructor.java
deleted file mode 100644
index d7ca49f..0000000
--- a/src/main/java/freemarker/template/utility/ObjectConstructor.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * 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. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package freemarker.template.utility;
-
-import java.util.List;
-
-import freemarker.ext.beans.BeansWrapper;
-import freemarker.template.TemplateMethodModelEx;
-import freemarker.template.TemplateModelException;
-
-/**
- * An object that you can make available in a template
- * to instantiate arbitrary beans-wrapped objects in a template.
- * Beware of this class's security implications. It allows
- * the instantiation of arbitrary objects and invoking
- * methods on them. Usage is something like:
- * <br>
- * <br>myDataModel.put("objectConstructor", new ObjectConstructor());
- * <br>
- * <br>And then from your FTL code:
- * <br>
- * <br><#assign aList = objectConstructor("java.util.ArrayList", 100)>
- */
-public class ObjectConstructor implements TemplateMethodModelEx {
- public Object exec(List args) throws TemplateModelException {
- if (args.isEmpty()) {
- throw new TemplateModelException("This method must have at least one argument, the name of the class to instantiate.");
- }
- String classname = args.get(0).toString();
- Class cl = null;
- try {
- cl = ClassUtil.forName(classname);
- } catch (Exception e) {
- throw new TemplateModelException(e.getMessage());
- }
- BeansWrapper bw = BeansWrapper.getDefaultInstance();
- Object obj = bw.newInstance(cl, args.subList(1, args.size()));
- return bw.wrap(obj);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/88d1d901/src/manual/en_US/FM3-CHANGE-LOG.txt
----------------------------------------------------------------------
diff --git a/src/manual/en_US/FM3-CHANGE-LOG.txt b/src/manual/en_US/FM3-CHANGE-LOG.txt
index 940b696..d7b1efb 100644
--- a/src/manual/en_US/FM3-CHANGE-LOG.txt
+++ b/src/manual/en_US/FM3-CHANGE-LOG.txt
@@ -3,10 +3,12 @@ the FreeMarer 3 changelog here:
- Increased version number to 3.0.0 (nightly aka. SNAPSHOT)
- Removed legacy extensions: rhyno, jython, xml (not to be confused with dom), jdom, ant.
-- Removed JSP 2.0 support (2.1 is the minimum for now, but maybe it will be 2.2 and Servlet 3.0 later).
+- Removed JSP 2.0 support (2.1 and Servlet 2.5 is the minimum for now, but maybe it will be 2.2 and Servlet 3.0 later).
- Removed freemarker.ext.log, our log abstraction layer from the old times when there was no clear winner on this field.
Added org.slf4j:slf4j-api as required dependency instead.
- Removed all classes with "main" methods that were part of freemarker.jar. Such tools should be separate artifacts,
not part of the library, and they are often classified as CWE-489 "Leftover Debug Code". The removed classes are:
freemarker.core.CommandLine, freemarker.ext.dom.Transform, freemarker.template.utility.ToCanonical
-- Removed classic_compatible (classicCompatible) setting, which was used to emulate some of the FreeMarker 1.x behavior
\ No newline at end of file
+- Removed classic_compatible (classicCompatible) setting, which was used to emulate some of the FreeMarker 1.x behavior
+- Removed utility TemplateModel-s that can very easily mean a security problem: freemarker.template.utility.Execute and
+ freemarker.template.utility.ObjectConstructor
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/88d1d901/src/test/java/freemarker/core/OptInTemplateClassResolverTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/freemarker/core/OptInTemplateClassResolverTest.java b/src/test/java/freemarker/core/OptInTemplateClassResolverTest.java
index d55f050..806058f 100644
--- a/src/test/java/freemarker/core/OptInTemplateClassResolverTest.java
+++ b/src/test/java/freemarker/core/OptInTemplateClassResolverTest.java
@@ -24,12 +24,11 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
-import junit.framework.AssertionFailedError;
-import junit.framework.TestCase;
import freemarker.template.Configuration;
import freemarker.template.Template;
import freemarker.template.TemplateException;
-import freemarker.template.utility.ObjectConstructor;
+import junit.framework.AssertionFailedError;
+import junit.framework.TestCase;
public class OptInTemplateClassResolverTest extends TestCase {
@@ -63,7 +62,7 @@ public class OptInTemplateClassResolverTest extends TestCase {
resolver.resolve("java.lang.Long", null, dummyTemp);
fail();
} catch (TemplateException e) {
- // good
+ // Expected
}
}
@@ -80,13 +79,6 @@ public class OptInTemplateClassResolverTest extends TestCase {
Template.getPlainTextTemplate("trusted.ftl", "", dummyCfg)));
assertEquals(Long.class, resolver.resolve("java.lang.Long", null,
Template.getPlainTextTemplate("/trusted.ftl", "", dummyCfg)));
- try {
- assertEquals(Long.class, resolver.resolve(ObjectConstructor.class.getName(), null,
- Template.getPlainTextTemplate("trusted.ftl", "", dummyCfg)));
- fail();
- } catch (TemplateException e) {
- // good
- }
}
public void testCraftedTrusted() throws TemplateException {
@@ -102,19 +94,19 @@ public class OptInTemplateClassResolverTest extends TestCase {
testTrusted_checkFails("lib/./foo.ftl");
fail();
} catch (AssertionFailedError e) {
- // good
+ // Expected
}
try {
testTrusted_checkFails("lib/foo..ftl");
fail();
} catch (AssertionFailedError e) {
- // good
+ // Expected
}
try {
testTrusted_checkFails("lib/%2e/foo.ftl");
fail();
} catch (AssertionFailedError e) {
- // good
+ // Expected
}
}
@@ -124,7 +116,7 @@ public class OptInTemplateClassResolverTest extends TestCase {
Template.getPlainTextTemplate(templateName, "", dummyCfg));
fail();
} catch (TemplateException e) {
- // good
+ // Expected
}
}
@@ -143,7 +135,7 @@ public class OptInTemplateClassResolverTest extends TestCase {
Template.getPlainTextTemplate("bar.ftl", "", cfg));
fail();
} catch (TemplateException e) {
- // good
+ // Expected
}
cfg.setSetting("new_builtin_class_resolver",
@@ -174,7 +166,7 @@ public class OptInTemplateClassResolverTest extends TestCase {
Template.getPlainTextTemplate("x.ftl", "", cfg));
fail();
} catch (TemplateException e) {
- // good
+ // Expected
}
assertEquals(Long.class, res.resolve("java.lang.Long", null,
Template.getPlainTextTemplate("foo.ftl", "", cfg)));
@@ -185,14 +177,14 @@ public class OptInTemplateClassResolverTest extends TestCase {
Template.getPlainTextTemplate("x.ftl", "", cfg));
fail();
} catch (TemplateException e) {
- // good
+ // Expected
}
try {
cfg.setSetting("new_builtin_class_resolver", "wrong: foo");
fail();
} catch (TemplateException e) {
- // good
+ // Expected
}
cfg.setSetting("new_builtin_class_resolver",
@@ -206,7 +198,7 @@ public class OptInTemplateClassResolverTest extends TestCase {
Template.getPlainTextTemplate("x.ftl", "", cfg));
fail();
} catch (TemplateException e) {
- // good
+ // Expected
}
assertEquals(Long.class, res.resolve("java.lang.Long", null,
Template.getPlainTextTemplate("lib:bar.ftl", "", cfg)));
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/88d1d901/src/test/resources/freemarker/test/templatesuite/expected/new-defaultresolver.txt
----------------------------------------------------------------------
diff --git a/src/test/resources/freemarker/test/templatesuite/expected/new-defaultresolver.txt b/src/test/resources/freemarker/test/templatesuite/expected/new-defaultresolver.txt
index 5d50e10..864da9b 100644
--- a/src/test/resources/freemarker/test/templatesuite/expected/new-defaultresolver.txt
+++ b/src/test/resources/freemarker/test/templatesuite/expected/new-defaultresolver.txt
@@ -16,5 +16,4 @@
* specific language governing permissions and limitations
* under the License.
*/
-works
works
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/88d1d901/src/test/resources/freemarker/test/templatesuite/expected/new-safer.txt
----------------------------------------------------------------------
diff --git a/src/test/resources/freemarker/test/templatesuite/expected/new-safer.txt b/src/test/resources/freemarker/test/templatesuite/expected/new-safer.txt
deleted file mode 100644
index d23943f..0000000
--- a/src/test/resources/freemarker/test/templatesuite/expected/new-safer.txt
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * 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. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-works
-fails
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/88d1d901/src/test/resources/freemarker/test/templatesuite/expected/new-unrestricted.txt
----------------------------------------------------------------------
diff --git a/src/test/resources/freemarker/test/templatesuite/expected/new-unrestricted.txt b/src/test/resources/freemarker/test/templatesuite/expected/new-unrestricted.txt
deleted file mode 100644
index 5d50e10..0000000
--- a/src/test/resources/freemarker/test/templatesuite/expected/new-unrestricted.txt
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * 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. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-works
-works
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/88d1d901/src/test/resources/freemarker/test/templatesuite/templates/new-allowsnothing.ftl
----------------------------------------------------------------------
diff --git a/src/test/resources/freemarker/test/templatesuite/templates/new-allowsnothing.ftl b/src/test/resources/freemarker/test/templatesuite/templates/new-allowsnothing.ftl
deleted file mode 100644
index 355d747..0000000
--- a/src/test/resources/freemarker/test/templatesuite/templates/new-allowsnothing.ftl
+++ /dev/null
@@ -1,23 +0,0 @@
-<#--
- 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. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-<#attempt>
-${"freemarker.test.templatesuite.models.NewTestModel"?new("works")}
-<#recover>
-fails
-</#attempt>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/88d1d901/src/test/resources/freemarker/test/templatesuite/templates/new-defaultresolver.ftl
----------------------------------------------------------------------
diff --git a/src/test/resources/freemarker/test/templatesuite/templates/new-defaultresolver.ftl b/src/test/resources/freemarker/test/templatesuite/templates/new-defaultresolver.ftl
index 333db6b..355d747 100644
--- a/src/test/resources/freemarker/test/templatesuite/templates/new-defaultresolver.ftl
+++ b/src/test/resources/freemarker/test/templatesuite/templates/new-defaultresolver.ftl
@@ -16,9 +16,8 @@
specific language governing permissions and limitations
under the License.
-->
-${"freemarker.test.templatesuite.models.NewTestModel"?new("works")}
<#attempt>
-${"freemarker.template.utility.ObjectConstructor"?new()("java.lang.String", "works")}
+${"freemarker.test.templatesuite.models.NewTestModel"?new("works")}
<#recover>
fails
</#attempt>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/88d1d901/src/test/resources/freemarker/test/templatesuite/templates/new-safer.ftl
----------------------------------------------------------------------
diff --git a/src/test/resources/freemarker/test/templatesuite/templates/new-safer.ftl b/src/test/resources/freemarker/test/templatesuite/templates/new-safer.ftl
deleted file mode 100644
index 333db6b..0000000
--- a/src/test/resources/freemarker/test/templatesuite/templates/new-safer.ftl
+++ /dev/null
@@ -1,24 +0,0 @@
-<#--
- 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. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-${"freemarker.test.templatesuite.models.NewTestModel"?new("works")}
-<#attempt>
-${"freemarker.template.utility.ObjectConstructor"?new()("java.lang.String", "works")}
-<#recover>
-fails
-</#attempt>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/88d1d901/src/test/resources/freemarker/test/templatesuite/templates/new-unrestricted.ftl
----------------------------------------------------------------------
diff --git a/src/test/resources/freemarker/test/templatesuite/templates/new-unrestricted.ftl b/src/test/resources/freemarker/test/templatesuite/templates/new-unrestricted.ftl
deleted file mode 100644
index ed9fd08..0000000
--- a/src/test/resources/freemarker/test/templatesuite/templates/new-unrestricted.ftl
+++ /dev/null
@@ -1,20 +0,0 @@
-<#--
- 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. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-${"freemarker.test.templatesuite.models.NewTestModel"?new("works")}
-${"freemarker.template.utility.ObjectConstructor"?new()("java.lang.String", "works")}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/88d1d901/src/test/resources/freemarker/test/templatesuite/testcases.xml
----------------------------------------------------------------------
diff --git a/src/test/resources/freemarker/test/templatesuite/testcases.xml b/src/test/resources/freemarker/test/templatesuite/testcases.xml
index d57cf50..2b59048 100644
--- a/src/test/resources/freemarker/test/templatesuite/testcases.xml
+++ b/src/test/resources/freemarker/test/templatesuite/testcases.xml
@@ -240,13 +240,13 @@
<testCase name="xml-ns_prefix-scope" template="xml-ns_prefix-scope-main.ftl" />
<testCase name="hashconcat"/>
<testCase name="new-defaultresolver" />
- <testCase name="new-unrestricted">
+ <testCase name="new-unrestricted" template="new-defaultresolver.ftl" expected="new-defaultresolver.txt">
<setting new_builtin_class_resolver="unrestricted"/>
</testCase>
- <testCase name="new-safer">
+ <testCase name="new-safer" template="new-defaultresolver.ftl" expected="new-defaultresolver.txt">
<setting new_builtin_class_resolver="safer"/>
</testCase>
- <testCase name="new-allowsnothing">
+ <testCase name="new-allowsnothing" template="new-defaultresolver.ftl">
<setting new_builtin_class_resolver="allows_nothing"/>
</testCase>
<testCase name="new-optin">