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 support for disabling $INCLUDE #67

Merged
merged 2 commits into from Jul 14, 2019
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

Next

Add support for disabling $INCLUDE

  - Add support for disabling $INCLUDE when parsing master files
  • Loading branch information...
jdreed committed Jun 27, 2019
commit 68c52d298971e4a30134d8bf7b8ccae7bc40a8eb
@@ -28,6 +28,8 @@
private Generator generator;
private List<Generator> generators;
private boolean noExpandGenerate;
private boolean noExpandIncludes;
private boolean includeThrowsException;

Master(File file, Name origin, long initialTTL) throws IOException {
if (origin != null && !origin.isAbsolute()) {
@@ -314,6 +316,12 @@ else if ((token.value).charAt(0) == '$') {
st.getEOL();
continue;
} else if (s.equalsIgnoreCase("$INCLUDE")) {
if (noExpandIncludes) {
if (includeThrowsException) {
throw st.exception("$INCLUDE encountered, but processing disabled in strict mode");
}
continue;
}
String filename = st.getString();
File newfile;
if (file != null) {
@@ -391,6 +399,34 @@ else if ((token.value).charAt(0) == '$') {
return rec;
}

/**
* Disable processing of $INCLUDE directives.
* When disabled, $INCUDE statements will not be processed.
* Depending on the contents of the file that would have been included,
* this may cause the zone to be invalid.
* (e.g. if there is no SOA or NS at the apex)
*/
public void
disableIncludes() {
noExpandIncludes = true;

This comment has been minimized.

Copy link
@ibauersachs

ibauersachs Jul 14, 2019

Member

Please call the overload instead of directly assigning variables: disableIncludes(false)

This comment has been minimized.

Copy link
@jdreed

jdreed Jul 14, 2019

Author Contributor

Updated with d9944b2. What is this project's preferred workflow? rebase and re-push to my branch? Or keep both commits?

This comment has been minimized.

Copy link
@ibauersachs

ibauersachs Jul 14, 2019

Member

Doesn't really matter to me. I often squash PRs during merge if there's no relevant history.

includeThrowsException = false;
}

/**
* Disable processing of $INCLUDE directives.
* When disabled, $INCUDE statements will not be processed.
* Depending on the contents of the file that would have been included,
* this may cause the zone to be invalid.
* (e.g. if there's no SOA or NS at the apex)
*
* @param strict If true, an exception will be thrown if $INCLUDE is encountered.
*/
public void
disableIncludes(boolean strict) {
noExpandIncludes = true;
includeThrowsException = strict;
}

/**
* Specifies whether $GENERATE statements should be expanded. Whether
* expanded or not, the specifications for generated records are available
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.