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

add option to disable escaping; update documentation #265

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
12 changes: 12 additions & 0 deletions panc-docs/src/docbkx/appendix/appendix-commands.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@

<arg>--nthread <replaceable>number</replaceable></arg>

<arg>--no-disable-escaping | --disable-escaping</arg>

<arg>--logging <replaceable>string</replaceable></arg>

<arg>--log-file <replaceable>file</replaceable></arg>
Expand Down Expand Up @@ -204,6 +206,16 @@
</listitem>
</varlistentry>

<varlistentry>
<term><option>--no-disable-escaping,
--disable-escaping</option></term>

<listitem>
<para>Enable or disable the escaping of path elements. The default
value is to enable the escaping of path elements.</para>
</listitem>
</varlistentry>

<varlistentry>
<term><option>--logging=<replaceable>string</replaceable></option></term>

Expand Down
16 changes: 16 additions & 0 deletions panc-docs/src/docbkx/appendix/appendix-run-panc.xml
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,14 @@ $ mvn clean install

<entry>No. Default value: 0.</entry>
</row>

<row>
<entry>disableEscaping</entry>

<entry>Disable the escaping of path elements.</entry>

<entry>No. Default value: false.</entry>
</row>
</tbody>
</tgroup>
</table>
Expand Down Expand Up @@ -640,6 +648,14 @@ $ mvn clean install

<entry>No. Default value: 0</entry>
</row>

<row>
<entry>disableEscaping</entry>

<entry>Disable the escaping of path elements.</entry>

<entry>No. Default value: false</entry>
</row>
</tbody>
</tgroup>
</table>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,14 @@ public class PanBuildMojo extends AbstractPanMojo {
*/
private int nthread = 0;

/**
* disable escaping/unescaping of path elements
*
* @parameter property="panc.disableEscaping" default-value=false
* @required
*/
private boolean disableEscaping = false;

/**
* logging types
*
Expand Down Expand Up @@ -155,7 +163,7 @@ private CompilerOptions createCompilerOptions()
return new CompilerOptions(Pattern.compile(debugNsInclude),
Pattern.compile(debugNsExclude), maxIteration,
maxRecursion, formatters, outputDir, includeDirectories,
warningsFromString(warnings), null, null, initialData, nthread);
warningsFromString(warnings), null, null, initialData, nthread, disableEscaping);

} catch (SyntaxException e) {
throw new MojoExecutionException(
Expand Down
17 changes: 11 additions & 6 deletions panc/src/main/clojure/org/quattor/pan/pan_compiler.clj
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ Please file a bug report including the stack trace.
annotationDirectory
annotationBaseDirectory
rootElement
nthread]} settings/*settings*]
nthread
disableEscaping]} settings/*settings*]
(CompilerOptions. debug-ns-include
debug-ns-exclude
max-iteration
Expand All @@ -47,7 +48,8 @@ Please file a bug report including the stack trace.
annotationDirectory
annotationBaseDirectory
rootElement
nthread)))
nthread
disableEscaping)))

(defn default-compiler-options []
(let [{:keys [debug-ns-include
Expand All @@ -61,7 +63,8 @@ Please file a bug report including the stack trace.
annotationDirectory
annotationBaseDirectory
rootElement
nthread]} (settings/defaults)]
nthread
disableEscaping]} (settings/defaults)]
(CompilerOptions. debug-ns-include
debug-ns-exclude
max-iteration
Expand All @@ -73,7 +76,8 @@ Please file a bug report including the stack trace.
annotationDirectory
annotationBaseDirectory
rootElement
nthread)))
nthread
disableEscaping)))

(defn parse-int
[^String s]
Expand All @@ -94,11 +98,12 @@ Please file a bug report including the stack trace.
[nil "--max-iteration LIMIT" "set max. no. of iterations" :default "10000"]
[nil "--max-recursion LIMIT" "set max. depth of recursion" :default "50"]
[nil "--nthread NUM" "no. of executor threads (0=no. CPU)" :default "0"]
[nil "--disable-escaping" "disable path element escaping" :default false]
[nil "--logging LOG_TYPES" "set logging types"]
[nil "--log-file FILE" "specify log file"]
[nil "--warnings FLAG" "off, on, fatal" :default "on"]
["-v" "--verbose" "show statistics and progress" :default false :flag true]
["-h" "--help" "print command help" :default false :flag true]])
["-v" "--verbose" "show statistics and progress" :default false]
["-h" "--help" "print command help" :default false]])

(defn banner-and-exit [banner]
(println (str "\npanc [options] [pan source files...]\n\n" banner))
Expand Down
3 changes: 2 additions & 1 deletion panc/src/main/clojure/org/quattor/pan/settings.clj
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
:annotationDirectory nil
:annotationBaseDirectory nil
:rootElement nil
:nthread 0})
:nthread 0
:disableEscaping false})

(def ^:dynamic *settings* (defaults))

Expand Down
12 changes: 11 additions & 1 deletion panc/src/main/java/org/quattor/ant/PanCompilerTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ public class PanCompilerTask extends Task {

private int nthread = 0;

private boolean disableEscaping = false;

private int maxIteration = 10000;

private int maxRecursion = 50;
Expand Down Expand Up @@ -136,7 +138,7 @@ public void execute() throws BuildException {
try {
options = new CompilerOptions(debugNsInclude, debugNsExclude,
maxIteration, maxRecursion, formatters, outputDir, includeDirectories,
deprecationWarnings, null, null, initialData, nthread);
deprecationWarnings, null, null, initialData, nthread, disableEscaping);
} catch (SyntaxException e) {
throw new BuildException("invalid root element: " + e.getMessage());
}
Expand Down Expand Up @@ -496,6 +498,14 @@ public void setNthread(int nthread) {
this.nthread = (nthread > 0) ? nthread : 0;
}

public boolean getDisableEscaping() {
return disableEscaping;
}

public void setDisableEscaping(boolean disableEscaping) {
this.disableEscaping = disableEscaping;
}

/**
* This utility method will group the file into a set of equal sized batches
* (except for possibly the last batch).
Expand Down
18 changes: 12 additions & 6 deletions panc/src/main/java/org/quattor/pan/CompilerOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ public static DeprecationWarnings fromString(String s) {

public final int nthread;

public final boolean disableEscapes;

/**
* Construct a CompilerOptions instance to drive a Compiler run. Instances
* of this class are immutable.
Expand Down Expand Up @@ -169,13 +171,16 @@ public static DeprecationWarnings fromString(String s) {
* @param nthread
* number of threads to use for each executor queue; 0 uses number
* of CPU cores on the machine
* @param disableEscapes
* disable the escaping and unescaping functions for path
* elements
* @throws SyntaxException
* if the expression for the rootElement is invalid
*/
public CompilerOptions(Pattern debugNsInclude, Pattern debugNsExclude, int maxIteration, int maxRecursion, Set
<Formatter> formatters,
File outputDirectory, List<File> includeDirectories, DeprecationWarnings deprecationWarnings, File annotationDirectory,
File annotationBaseDirectory, String rootElement, int nthread)
File annotationBaseDirectory, String rootElement, int nthread, boolean disableEscapes)
throws SyntaxException {

// Check that the iteration and call depth limits are sensible. If
Expand Down Expand Up @@ -260,6 +265,8 @@ public CompilerOptions(Pattern debugNsInclude, Pattern debugNsExclude, int maxIt
} else {
this.nthread = nthread;
}

this.disableEscapes = disableEscapes;
}

// Utility method to turn old options into new deprecation flag.
Expand Down Expand Up @@ -299,7 +306,7 @@ public static CompilerOptions createCheckSyntaxOptions(
return new CompilerOptions(debugNsInclude, debugNsExclude,
maxIteration, maxRecursion, formatters, outputDirectory,
includeDirectories, deprecationWarnings,
annotationDirectory, annotationBaseDirectory, null, 0);
annotationDirectory, annotationBaseDirectory, null, 0, false);

} catch (SyntaxException consumed) {
throw CompilerError.create(MSG_FILE_BUG_REPORT);
Expand Down Expand Up @@ -330,7 +337,7 @@ public static CompilerOptions createAnnotationOptions(
return new CompilerOptions(debugNsInclude, debugNsExclude,
maxIteration, maxRecursion, formatters, outputDirectory,
includeDirectories, DeprecationWarnings.OFF,
annotationDirectory, annotationBaseDirectory, null, 0);
annotationDirectory, annotationBaseDirectory, null, 0, false);

} catch (SyntaxException consumed) {
throw CompilerError.create(MSG_FILE_BUG_REPORT);
Expand Down Expand Up @@ -418,9 +425,8 @@ public Set<File> resolveFileList(List<String> objectNames,
if (!source.isAbsent()) {
filesToProcess.add(source.getPath());
} else {
throw EvaluationException.create((SourceRange) null,
(Context) null, MSG_CANNOT_LOCATE_OBJECT_TEMPLATE,
oname);
throw EvaluationException.create((SourceRange) null, (Context) null,
MSG_CANNOT_LOCATE_OBJECT_TEMPLATE, oname);
}
}
}
Expand Down
16 changes: 8 additions & 8 deletions panc/src/test/java/org/quattor/pan/CompilerOptionsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void testConstructorAndGetters1() throws SyntaxException {
CompilerOptions options = new CompilerOptions(null, null,
iterationLimit, callDepthLimit, formatters, outputDirectory,
includeDirectories, CompilerOptions.DeprecationWarnings.ON,
null, null, null, 0);
null, null, null, 0, false);

assertTrue(iterationLimit == options.maxIteration);
assertTrue(callDepthLimit == options.maxRecursion);
Expand All @@ -84,7 +84,7 @@ public void testConstructorAndGetters2() throws SyntaxException {
CompilerOptions options = new CompilerOptions(null, null,
iterationLimit, callDepthLimit, formatters, outputDirectory,
includeDirectories, CompilerOptions.DeprecationWarnings.ON,
null, null, null, 0);
null, null, null, 0, false);

assertTrue(iterationLimit == options.maxIteration);
assertTrue(callDepthLimit == options.maxRecursion);
Expand All @@ -110,7 +110,7 @@ public void checkUnlimitedValues() throws SyntaxException {
CompilerOptions options = new CompilerOptions(null, null,
iterationLimit, callDepthLimit, formatters, outputDirectory,
includeDirectories, CompilerOptions.DeprecationWarnings.ON,
null, null, null, 0);
null, null, null, 0, false);

assertTrue(Integer.MAX_VALUE == options.maxIteration);
assertTrue(Integer.MAX_VALUE == options.maxRecursion);
Expand All @@ -131,7 +131,7 @@ public void checkBadOutputDirectory() throws SyntaxException {

new CompilerOptions(null, null, iterationLimit, callDepthLimit,
formatters, outputDirectory, includeDirectories,
CompilerOptions.DeprecationWarnings.ON, null, null, null, 0);
CompilerOptions.DeprecationWarnings.ON, null, null, null, 0, false);
}

@Test(expected = IllegalArgumentException.class)
Expand All @@ -149,7 +149,7 @@ public void checkIncludeDirectory() throws SyntaxException {

new CompilerOptions(null, null, iterationLimit, callDepthLimit,
formatters, outputDirectory, includeDirectories,
CompilerOptions.DeprecationWarnings.ON, null, null, null, 0);
CompilerOptions.DeprecationWarnings.ON, null, null, null, 0, false);
}

@Test(expected = IllegalArgumentException.class)
Expand All @@ -167,7 +167,7 @@ public void checkMissingOutputDirectory1() throws SyntaxException {

new CompilerOptions(null, null, iterationLimit, callDepthLimit,
formatters, outputDirectory, includeDirectories,
CompilerOptions.DeprecationWarnings.ON, null, null, null, 0);
CompilerOptions.DeprecationWarnings.ON, null, null, null, 0, false);
}

@Test(expected = IllegalArgumentException.class)
Expand All @@ -184,7 +184,7 @@ public void checkMissingOutputDirectory2() throws SyntaxException {

new CompilerOptions(null, null, iterationLimit, callDepthLimit,
formatters, outputDirectory, includeDirectories,
CompilerOptions.DeprecationWarnings.ON, null, null, null, 0);
CompilerOptions.DeprecationWarnings.ON, null, null, null, 0, false);
}

@Test(expected = IllegalArgumentException.class)
Expand All @@ -202,7 +202,7 @@ public void checkNullIncludeDirectory() throws SyntaxException {

new CompilerOptions(null, null, iterationLimit, callDepthLimit,
formatters, outputDirectory, includeDirectories,
CompilerOptions.DeprecationWarnings.ON, null, null, null, 0);
CompilerOptions.DeprecationWarnings.ON, null, null, null, 0, false);
}

@Test
Expand Down
10 changes: 5 additions & 5 deletions panc/src/test/java/org/quattor/pan/JavaCompilerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ protected Compiler getDefaultCompiler(File tplfile, File dir,
formatters.add(DepFormatter.getInstance());
CompilerOptions options = new CompilerOptions(null, null, 100, 50,
formatters, getTmpdir(), path,
CompilerOptions.DeprecationWarnings.ON, null, null, null, 0);
CompilerOptions.DeprecationWarnings.ON, null, null, null, 0, false);
List<File> tplfiles = new LinkedList<File>();
tplfiles.add(tplfile);
return new Compiler(options, new LinkedList<String>(), tplfiles);
Expand All @@ -86,7 +86,7 @@ protected Compiler getRootElementCompiler(File tplfile, File dir,
CompilerOptions options = new CompilerOptions(null, null, 100, 50,
formatters, getTmpdir(), path,
CompilerOptions.DeprecationWarnings.ON, null, null,
"nlist('root-element-test', 'OK')", 0);
"nlist('root-element-test', 'OK')", 0, false);
List<File> tplfiles = new LinkedList<File>();
tplfiles.add(tplfile);
return new Compiler(options, new LinkedList<String>(), tplfiles);
Expand All @@ -103,7 +103,7 @@ protected Compiler getDependencyCompiler(File tplfile, File dir)
formatters.add(DepFormatter.getInstance());
CompilerOptions options = new CompilerOptions(null, null, 100, 50,
formatters, getTmpdir(), path,
CompilerOptions.DeprecationWarnings.ON, null, null, null, 0);
CompilerOptions.DeprecationWarnings.ON, null, null, null, 0, false);
List<File> tplfiles = new LinkedList<File>();
tplfiles.add(tplfile);
return new Compiler(options, new LinkedList<String>(), tplfiles);
Expand All @@ -122,7 +122,7 @@ public void testErrorOnMissingObjectFile() throws SyntaxException {
formatters.add(DepFormatter.getInstance());
CompilerOptions options = new CompilerOptions(null, null, 100, 50,
formatters, getTmpdir(), path,
CompilerOptions.DeprecationWarnings.ON, null, null, null, 0);
CompilerOptions.DeprecationWarnings.ON, null, null, null, 0, false);

List<String> objects = new LinkedList<String>();
objects.add("non-existant/object/template");
Expand Down Expand Up @@ -168,7 +168,7 @@ public void testErrorOnMisplacedObjectFile() throws FileNotFoundException,

CompilerOptions options = new CompilerOptions(null, null, 100, 50,
formatters, tmpdir, path,
CompilerOptions.DeprecationWarnings.ON, null, null, null, 0);
CompilerOptions.DeprecationWarnings.ON, null, null, null, 0, false);

// Create the list of input files.
List<File> tplfiles = new LinkedList<File>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ protected void runExpectingException(String name, String statement)

CompilerOptions options = new CompilerOptions(null, null, 1000, 50,
formatters, tmpfile, paths, CompilerOptions.DeprecationWarnings.OFF, null, null,
null, 0);
null, 0, false);

Compiler compiler = new Compiler(options, new LinkedList<String>(),
files);
Expand Down Expand Up @@ -124,7 +124,7 @@ protected Context setupTemplateToRun2(String name, String statement,

CompilerOptions options = new CompilerOptions(null, null, 1000, 50,
formatters, tmpfile, paths, CompilerOptions.DeprecationWarnings.OFF, null, null,
null, 0);
null, 0, false);

Compiler compiler = new Compiler(options, new LinkedList<String>(),
files);
Expand Down Expand Up @@ -176,7 +176,7 @@ protected Context setupTemplateToRun3(String name, String statement1,

CompilerOptions options = new CompilerOptions(null, null, 1000, 50,
formatters, tmpfile, paths, CompilerOptions.DeprecationWarnings.OFF, null, null,
null, 0);
null, 0, false);

Compiler compiler = new Compiler(options, new LinkedList<String>(),
files);
Expand Down