@@ -28,6 +28,8 @@ public class Master implements AutoCloseable {
2828private Generator generator ;
2929private List <Generator > generators ;
3030private boolean noExpandGenerate ;
31+ private boolean noExpandIncludes ;
32+ private boolean includeThrowsException ;
3133
3234Master (File file , Name origin , long initialTTL ) throws IOException {
3335 if (origin != null && !origin .isAbsolute ()) {
@@ -314,6 +316,12 @@ else if ((token.value).charAt(0) == '$') {
314316 st .getEOL ();
315317 continue ;
316318 } else if (s .equalsIgnoreCase ("$INCLUDE" )) {
319+ if (noExpandIncludes ) {
320+ if (includeThrowsException ) {
321+ throw st .exception ("$INCLUDE encountered, but processing disabled in strict mode" );
322+ }
323+ continue ;
324+ }
317325 String filename = st .getString ();
318326 File newfile ;
319327 if (file != null ) {
@@ -391,6 +399,33 @@ else if ((token.value).charAt(0) == '$') {
391399 return rec ;
392400}
393401
402+ /**
403+ * Disable processing of $INCLUDE directives.
404+ * When disabled, $INCUDE statements will not be processed.
405+ * Depending on the contents of the file that would have been included,
406+ * this may cause the zone to be invalid.
407+ * (e.g. if there is no SOA or NS at the apex)
408+ */
409+ public void
410+ disableIncludes () {
411+ disableIncludes (false );
412+ }
413+
414+ /**
415+ * Disable processing of $INCLUDE directives.
416+ * When disabled, $INCUDE statements will not be processed.
417+ * Depending on the contents of the file that would have been included,
418+ * this may cause the zone to be invalid.
419+ * (e.g. if there's no SOA or NS at the apex)
420+ *
421+ * @param strict If true, an exception will be thrown if $INCLUDE is encountered.
422+ */
423+ public void
424+ disableIncludes (boolean strict ) {
425+ noExpandIncludes = true ;
426+ includeThrowsException = strict ;
427+ }
428+
394429/**
395430 * Specifies whether $GENERATE statements should be expanded. Whether
396431 * expanded or not, the specifications for generated records are available
0 commit comments