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/20 21:46:35 UTC
incubator-freemarker git commit: 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
class
Repository: incubator-freemarker
Updated Branches:
refs/heads/3 8952cbbba -> 38642f504
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
Project: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/commit/38642f50
Tree: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/tree/38642f50
Diff: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/diff/38642f50
Branch: refs/heads/3
Commit: 38642f504b9471e8e9adb8cbb7e6804f01020905
Parents: 8952cbb
Author: ddekany <dd...@apache.org>
Authored: Fri Jan 20 22:46:09 2017 +0100
Committer: ddekany <dd...@apache.org>
Committed: Fri Jan 20 22:46:21 2017 +0100
----------------------------------------------------------------------
osgi.bnd | 1 -
src/main/java/freemarker/core/CommandLine.java | 60 ------
src/main/java/freemarker/ext/dom/Transform.java | 213 -------------------
.../template/utility/ToCanonical.java | 80 -------
src/manual/en_US/FM3-CHANGE-LOG.txt | 5 +-
5 files changed, 4 insertions(+), 355 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/38642f50/osgi.bnd
----------------------------------------------------------------------
diff --git a/osgi.bnd b/osgi.bnd
index 9cc8cd8..e1c7acb 100644
--- a/osgi.bnd
+++ b/osgi.bnd
@@ -55,7 +55,6 @@ DynamicImport-Package: *
Bundle-RequiredExecutionEnvironment: J2SE-1.5, J2SE-1.4
# Non-OSGi meta:
-Main-Class: freemarker.core.CommandLine
Extension-name: FreeMarker
Specification-Title: FreeMarker
Specification-Version: ${versionForMf}
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/38642f50/src/main/java/freemarker/core/CommandLine.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/CommandLine.java b/src/main/java/freemarker/core/CommandLine.java
deleted file mode 100644
index 6e4e29f..0000000
--- a/src/main/java/freemarker/core/CommandLine.java
+++ /dev/null
@@ -1,60 +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.core;
-
-import freemarker.template.Configuration;
-import freemarker.template.Version;
-import freemarker.template.utility.DateUtil;
-
-/**
- * FreeMarker command-line utility, the Main-Class of <tt>freemarker.jar</tt>.
- * Currently it just prints the version number.
- *
- * @deprecated Will be removed (main method in a library, often classified as CWE-489 "Leftover Debug Code").
- */
-@Deprecated
-public class CommandLine {
-
- public static void main(String[] args) {
- Version ver = Configuration.getVersion();
-
- System.out.println();
- System.out.print("Apache FreeMarker version ");
- System.out.print(ver);
-
- /* If the version number doesn't already contain the build date and it's known, print it: */
- if (!ver.toString().endsWith("Z")
- && ver.getBuildDate() != null) {
- System.out.print(" (built on ");
- System.out.print(DateUtil.dateToISO8601String(
- ver.getBuildDate(),
- true, true, true, DateUtil.ACCURACY_SECONDS,
- DateUtil.UTC,
- new DateUtil.TrivialDateToISO8601CalendarFactory()));
- System.out.print(")");
- }
- System.out.println();
-
- if (ver.isGAECompliant() != null) {
- System.out.print("Google App Engine complian variant: ");
- System.out.println(ver.isGAECompliant().booleanValue() ? "Yes" : "No");
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/38642f50/src/main/java/freemarker/ext/dom/Transform.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/ext/dom/Transform.java b/src/main/java/freemarker/ext/dom/Transform.java
deleted file mode 100644
index 5df9683..0000000
--- a/src/main/java/freemarker/ext/dom/Transform.java
+++ /dev/null
@@ -1,213 +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.ext.dom;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.Writer;
-import java.util.Locale;
-import java.util.StringTokenizer;
-
-import freemarker.core.Environment;
-import freemarker.template.Configuration;
-import freemarker.template.Template;
-
-/**
- * A class that contains a main() method for command-line invocation of a FreeMarker XML transformation.
- *
- * @deprecated Will be removed (main method in a library, often classified as CWE-489 "Leftover Debug Code").
- */
-@Deprecated
-public class Transform {
-
- private File inputFile, ftlFile, outputFile;
- private String encoding;
- private Locale locale;
- private Configuration cfg;
-
- /**
- * @deprecated Will be removed (main method in a library, often classified as CWE-489 "Leftover Debug Code").
- */
- @Deprecated
- static public void main(String[] args) {
- try {
- Transform proc = transformFromArgs(args);
- proc.transform();
- } catch (IllegalArgumentException iae) {
- System.err.println(iae.getMessage());
- usage();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- /**
- * @param inputFile
- * The file from which to read the XML input
- * @param ftlFile
- * The file containing the template
- * @param outputFile
- * The file to which to output. If this is null, we use stdout.
- * @param locale
- * The locale to use. If this is null, we use the platform default.
- * @param encoding
- * The character encoding to use for output, if this is null, we use the platform default
- */
- Transform(File inputFile, File ftlFile, File outputFile, Locale locale, String encoding) throws IOException {
- if (encoding == null) {
- encoding = System.getProperty("file.encoding");
- }
- if (locale == null) {
- locale = Locale.getDefault();
- }
- this.encoding = encoding;
- this.locale = locale;
- this.inputFile = inputFile;
- this.ftlFile = ftlFile;
- this.outputFile = outputFile;
- File ftlDirectory = ftlFile.getAbsoluteFile().getParentFile();
- cfg = new Configuration();
- cfg.setDirectoryForTemplateLoading(ftlDirectory);
- }
-
- /**
- * Performs the transformation.
- */
- void transform() throws Exception {
- String templateName = ftlFile.getName();
- Template template = cfg.getTemplate(templateName, locale);
- NodeModel rootNode = NodeModel.parse(inputFile);
- OutputStream outputStream = System.out;
- if (outputFile != null) {
- outputStream = new FileOutputStream(outputFile);
- }
- Writer outputWriter = new OutputStreamWriter(outputStream, encoding);
- try {
- template.process(null, outputWriter, null, rootNode);
- } finally {
- if (outputFile != null)
- outputWriter.close();
- }
- }
-
- static Transform transformFromArgs(String[] args) throws IOException {
- int i = 0;
- String input = null, output = null, ftl = null, loc = null, enc = null;
- while (i < args.length) {
- String dashArg = args[i++];
- if (i >= args.length) {
- throw new IllegalArgumentException("");
- }
- String arg = args[i++];
- if (dashArg.equals("-in")) {
- if (input != null) {
- throw new IllegalArgumentException("The input file should only be specified once");
- }
- input = arg;
- } else if (dashArg.equals("-ftl")) {
- if (ftl != null) {
- throw new IllegalArgumentException("The ftl file should only be specified once");
- }
- ftl = arg;
- } else if (dashArg.equals("-out")) {
- if (output != null) {
- throw new IllegalArgumentException("The output file should only be specified once");
- }
- output = arg;
- } else if (dashArg.equals("-locale")) {
- if (loc != null) {
- throw new IllegalArgumentException("The locale should only be specified once");
- }
- loc = arg;
- } else if (dashArg.equals("-encoding")) {
- if (enc != null) {
- throw new IllegalArgumentException("The encoding should only be specified once");
- }
- enc = arg;
- } else {
- throw new IllegalArgumentException("Unknown input argument: " + dashArg);
- }
- }
- if (input == null) {
- throw new IllegalArgumentException("No input file specified.");
- }
- if (ftl == null) {
- throw new IllegalArgumentException("No ftl file specified.");
- }
- File inputFile = new File(input).getAbsoluteFile();
- File ftlFile = new File(ftl).getAbsoluteFile();
- if (!inputFile.exists()) {
- throw new IllegalArgumentException("Input file does not exist: " + input);
- }
- if (!ftlFile.exists()) {
- throw new IllegalArgumentException("FTL file does not exist: " + ftl);
- }
- if (!inputFile.isFile() || !inputFile.canRead()) {
- throw new IllegalArgumentException("Input file must be a readable file: " + input);
- }
- if (!ftlFile.isFile() || !ftlFile.canRead()) {
- throw new IllegalArgumentException("FTL file must be a readable file: " + ftl);
- }
- File outputFile = null;
- if (output != null) {
- outputFile = new File(output).getAbsoluteFile();
- File outputDirectory = outputFile.getParentFile();
- if (!outputDirectory.exists() || !outputDirectory.canWrite()) {
- throw new IllegalArgumentException("The output directory must exist and be writable: "
- + outputDirectory);
- }
- }
- Locale locale = Locale.getDefault();
- if (loc != null) {
- locale = localeFromString(loc);
- }
- return new Transform(inputFile, ftlFile, outputFile, locale, enc);
- }
-
- static Locale localeFromString(String ls) {
- if (ls == null) ls = "";
- String lang = "", country = "", variant = "";
- StringTokenizer st = new StringTokenizer(ls, "_-,");
- if (st.hasMoreTokens()) {
- lang = st.nextToken();
- if (st.hasMoreTokens()) {
- country = st.nextToken();
- if (st.hasMoreTokens()) {
- variant = st.nextToken();
- }
- }
- return new Locale(lang, country, variant);
- } else {
- return Locale.getDefault();
- }
- }
-
- static void usage() {
- System.err
- .println("Usage: java freemarker.ext.dom.Transform -in <xmlfile> -ftl <ftlfile> [-out <outfile>] [-locale <locale>] [-encoding <encoding>]");
- // Security: prevents shutting down the container from a template:
- if (Environment.getCurrentEnvironment() == null) {
- System.exit(-1);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/38642f50/src/main/java/freemarker/template/utility/ToCanonical.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/template/utility/ToCanonical.java b/src/main/java/freemarker/template/utility/ToCanonical.java
deleted file mode 100644
index 8f15223..0000000
--- a/src/main/java/freemarker/template/utility/ToCanonical.java
+++ /dev/null
@@ -1,80 +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.File;
-import java.io.FileWriter;
-import java.io.IOException;
-
-import freemarker.template.Configuration;
-import freemarker.template.Template;
-
-/**
- * Read in a template and convert it to a canonical format.
- *
- * @deprecated Will be removed (main method in a library, often classified as CWE-489 "Leftover Debug Code").
- */
-@Deprecated
-public class ToCanonical {
-
- static Configuration config = Configuration.getDefaultConfiguration();
-
- /**
- * @deprecated Will be removed (main method in a library, often classified as CWE-489 "Leftover Debug Code").
- */
- @Deprecated
- static public void main(String[] args) {
- config.setWhitespaceStripping(false);
- if (args.length == 0) {
- usage();
- }
- for (int i = 0; i < args.length; i++) {
- File f = new File(args[i]);
- if (!f.exists()) {
- System.err.println("File " + f + " doesn't exist.");
- }
- try {
- convertFile(f);
- } catch (Exception e) {
- System.err.println("Error converting file: " + f);
- e.printStackTrace();
- }
- }
- }
-
- static void convertFile(File f) throws IOException {
- File fullPath = f.getAbsoluteFile();
- File dir = fullPath.getParentFile();
- String filename = fullPath.getName();
- File convertedFile = new File(dir, filename + ".canonical");
- config.setDirectoryForTemplateLoading(dir);
- Template template = config.getTemplate(filename);
- FileWriter output = new FileWriter(convertedFile);
- try {
- template.dump(output);
- } finally {
- output.close();
- }
- }
-
- static void usage() {
- System.err.println("Usage: java freemarker.template.utility.ToCanonical <filename(s)>");
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/38642f50/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 5c526c4..5311e9c 100644
--- a/src/manual/en_US/FM3-CHANGE-LOG.txt
+++ b/src/manual/en_US/FM3-CHANGE-LOG.txt
@@ -5,4 +5,7 @@ the FreeMarer 3 changelog here:
- 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 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.
\ No newline at end of file
+ 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
\ No newline at end of file